Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package bcal for openSUSE:Factory checked in at 2021-03-17 20:16:28 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/bcal (Old) and /work/SRC/openSUSE:Factory/.bcal.new.2401 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "bcal" Wed Mar 17 20:16:28 2021 rev:4 rq:879546 version:2.2 Changes: -------- --- /work/SRC/openSUSE:Factory/bcal/bcal.changes 2019-06-05 11:46:28.606991091 +0200 +++ /work/SRC/openSUSE:Factory/.bcal.new.2401/bcal.changes 2021-03-17 20:19:59.547320598 +0100 @@ -1,0 +2,13 @@ +Wed Mar 17 03:07:01 UTC 2021 - Wang Jun <[email protected]> + +- Update to version 2.2 + * Support [`calc`](http://www.isthe.com/chongo/tech/comp/calc/) + for multi-base expressions + * To use `calc`, `export BCAL_USE_CALC=1` + * Fix lint issues + * Fix issue #30 + * Updated auto-generated packages + * More portable Makefile + * Delete bcal-2.1_gcc9.patch, it was merged into upsteam. + +------------------------------------------------------------------- Old: ---- bcal-2.1.tar.gz bcal-2.1_gcc9.patch New: ---- bcal-2.2.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ bcal.spec ++++++ --- /var/tmp/diff_new_pack.rMdq6i/_old 2021-03-17 20:20:00.027321254 +0100 +++ /var/tmp/diff_new_pack.rMdq6i/_new 2021-03-17 20:20:00.031321259 +0100 @@ -1,7 +1,7 @@ # # spec file for package bcal # -# Copyright (c) 2019 SUSE LINUX GmbH, Nuernberg, Germany. +# Copyright (c) 2021 SUSE LLC # Copyright (c) 2018 Dilawar Singh <[email protected]> # # All modifications and additions to the file contributed by third parties @@ -22,11 +22,9 @@ License: GPL-3.0-only Group: Productivity/Scientific/Math URL: http://www.github.com/jarun/bcal -Version: 2.1 +Version: 2.2 Release: 0 Source0: https://github.com/jarun/bcal/archive/v%{version}.tar.gz#/%{name}-%{version}.tar.gz -# PATCH-FIX-UPSTREAM bcal-2.1_gcc9.patch -Patch0: bcal-2.1_gcc9.patch BuildRequires: readline-devel ExcludeArch: %ix86 %arm %ppc @@ -39,7 +37,6 @@ %prep %setup -q -%patch0 -p1 %build export CFLAGS="%{optflags}" ++++++ bcal-2.1.tar.gz -> bcal-2.2.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/bcal-2.1/.clang-tidy new/bcal-2.2/.clang-tidy --- old/bcal-2.1/.clang-tidy 2018-12-11 16:12:41.000000000 +0100 +++ new/bcal-2.2/.clang-tidy 2020-01-07 15:45:52.000000000 +0100 @@ -1,5 +1,5 @@ --- -Checks: 'clang-diagnostic-*,clang-analyzer-*,readability-*,modernize-*,bugprone-*,misc-*,-misc-unused-parameters,google-runtime-int,-llvm-header-guard,fuchsia-restrict-system-includes,-clang-analyzer-valist.Uninitialized,-clang-analyzer-security.insecureAPI.rand,-clang-analyzer-alpha.*,-readability-magic-numbers,-readability-braces-around-statements' +Checks: 'clang-diagnostic-*,clang-analyzer-*,readability-*,modernize-*,bugprone-*,misc-*,-misc-unused-parameters,google-runtime-int,-llvm-header-guard,fuchsia-restrict-system-includes,-clang-analyzer-valist.Uninitialized,-clang-analyzer-security.insecureAPI.rand,-clang-analyzer-alpha.*,-readability-magic-numbers,-readability-braces-around-statements,-readability-isolate-declaration' WarningsAsErrors: '*' HeaderFilterRegex: '.*(?<!lookup3.c)$' FormatStyle: 'file' diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/bcal-2.1/.github/FUNDING.yml new/bcal-2.2/.github/FUNDING.yml --- old/bcal-2.1/.github/FUNDING.yml 1970-01-01 01:00:00.000000000 +0100 +++ new/bcal-2.2/.github/FUNDING.yml 2020-01-07 15:45:52.000000000 +0100 @@ -0,0 +1 @@ +custom: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=RMLTQ76JSXJ4Q diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/bcal-2.1/.travis.yml new/bcal-2.2/.travis.yml --- old/bcal-2.1/.travis.yml 2018-12-11 16:12:41.000000000 +0100 +++ new/bcal-2.2/.travis.yml 2020-01-07 15:45:52.000000000 +0100 @@ -62,7 +62,7 @@ deploy: provider: releases api-key: - secure: ZtMbo/H21MoodNvw7+tvPId97meS4Xs2beUzqOhI166iuaLSWtjXxQgeC7vdYTWgPNacN6gxwhnXTLMXpt81a7g0NWxjRQ72/Rwh7aCdgQkJI/Y+0c7RNNVdLOtAWBM8csPoJy0jFdI34yHRj053tm9x65V4fMEKC9ArRm7pbTjNNovYXbW2KmRh6kr3dJdB/7tpoCpiMov6l4uHyWIcniFx97P+3dGnGqBd8SpR3IxeEypm8fzIGiX7NIJqwyG5MbLaWoyloBu21ilwh07dDifF6MI4mrkxtGY0yQ9GtHVp5cr7qyMgCt60hUGtrKhTtPQWwpzK0GSZ5eeYiLt6I/kkcj8FkWP+OazRLy/MydjGtG7q8tnbgNcmGqsbv+g1jJMEfZsnTfozeGOPPsYlhB/7kCi2BVqguXlKMRmpNPMZsc4HYK9yjV4HNsEkmwJcXgD350XS5iFu/koIGiT2PJ+/msdwPir74JpgRn00iGC0fD25V8M2TRnKn43g6jNRAZYMITaYDx+ML0SkdWIjksalW0759BgLfQopNbs9a9PbsKiNbfRRRF3xA8j2fQI6my7hXx0TzRwWTC7aMAuJkdjKn5UYOrMAZ+VXhHSOcX5LPiefwgtoU0YGjgWQdgTkQ7aR13rKuDSKepGonnkyiHWnM9gGftnNbNFi7WZRk5w= + secure: u83OMgj7hh+PWsBKE95FVB9eXionEu6W9drx6xWAhqJgqAlCtPFBb0MLimJCXBN0cStAfSHPGp4ovd+3oiimvzBoVH6Kx/ySWQ0vMU6L/1lNMVuE+Z/mxI98eQFR5fC/TMYWHD4+KyTs9CIN/DMZ+CZVbuAtr9neMmjx3fWfqSNQw7VUhP/IVQOFze0FJAdeqp0tPjXPnsA2eRLhmypR+1kHx2v7iy2NmC5Gk/qzpsuihW+U6Eg6e2SFBxEzLSylqJHC9/nPItqFSrhghUasK6ofJ72A5CaAZ5J0KWug1lJDrx6bNUmR4J1bBYR+vp2es73I7eKTBQ0FFWJrSvIJ62DowL2wxhr6xeyaILADykchxaawXNNxyapOr7feGLjPMb0Cxh5w9dfNXIWoRGSQGrERr+TDLgIXZENqYVjNklQg3HK9J5gD9EWn2qmm9NPZ1c3JUOCW/4kf7FLLlbSDUO3VGdQXVyYKpo5vgoZr7MG9zFb7aFWeDeQJRDd+c4TaSuqgt4l1Krn2Pfg9zjv2dDQHS3ZlumvwHJtebLpzOKfmNCmeKFIROCXVT6ml4QxTj3mjy6ddWlulL9mxF79z8bgGYQ9f/gplfQ0shEOnmoJnSsvmw7nPFBsNRSAfyDJQ2TaJ1wgMOu6IfN9yNIo93AaUFKGTKzYk0g/Skg2Avy8= file_glob: true file: - dist/* diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/bcal-2.1/CHANGELOG new/bcal-2.2/CHANGELOG --- old/bcal-2.1/CHANGELOG 2018-12-11 16:12:41.000000000 +0100 +++ new/bcal-2.2/CHANGELOG 2020-01-07 15:45:52.000000000 +0100 @@ -1,3 +1,16 @@ +bcal v2.2 +2020-01-07 + +What's in? +- Support [`calc`](http://www.isthe.com/chongo/tech/comp/calc/) for multi-base expressions +- To use `calc`, `export BCAL_USE_CALC=1` +- Fix lint issues +- Fix issue #30 +- Updated auto-generated packages +- More portable Makefile + +------------------------------------------------------------------------------- + bcal v2.1 2018-12-11 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/bcal-2.1/Makefile new/bcal-2.2/Makefile --- old/bcal-2.1/Makefile 2018-12-11 16:12:41.000000000 +0100 +++ new/bcal-2.2/Makefile 2020-01-07 15:45:52.000000000 +0100 @@ -4,20 +4,24 @@ DOCDIR = $(DESTDIR)$(PREFIX)/share/doc/bcal STRIP ?= strip -CFLAGS ?= -O3 -CFLAGS += -Wall -Wextra -Wno-unused-parameter -Werror -LDLIBS = -lreadline +CFLAGS_OPTIMIZATION ?= -O3 +CFLAGS_WARNINGS ?= -Wall -Wextra -Wno-unused-parameter -Werror + +LDLIBS_READLINE ?= -lreadline + +CFLAGS += $(CFLAGS_OPTIMIZATION) $(CFLAGS_WARNINGS) +LDLIBS += $(LDLIBS_READLINE) SRC = $(wildcard src/*.c) INCLUDE = -Iinc bcal: $(SRC) - $(CC) $(CFLAGS) $(INCLUDE) -o bcal $(SRC) $(LDLIBS) + $(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) $(INCLUDE) -o bcal $(SRC) $(LDLIBS) all: bcal x86: $(SRC) - $(CC) -m64 $(CFLAGS) $(INCLUDE) -o bcal $(SRC) $(LDLIBS) + $(CC) -m64 $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) $(INCLUDE) -o bcal $(SRC) $(LDLIBS) strip bcal distclean: clean diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/bcal-2.1/README.md new/bcal-2.2/README.md --- old/bcal-2.1/README.md 2018-12-11 16:12:41.000000000 +0100 +++ new/bcal-2.2/README.md 2020-01-07 15:45:52.000000000 +0100 @@ -2,15 +2,7 @@ <p align="center"> <a href="https://github.com/jarun/bcal/releases/latest"><img src="https://img.shields.io/github/release/jarun/bcal.svg?maxAge=600" alt="Latest release" /></a> -<a href="https://aur.archlinux.org/packages/bcal"><img src="https://img.shields.io/aur/version/bcal.svg?maxAge=600" alt="AUR" /></a> -<a href="http://formulae.brew.sh/formula/bcal"><img src="https://img.shields.io/homebrew/v/bcal.svg?maxAge=600" alt="Homebrew" /></a> -<a href="https://packages.debian.org/search?keywords=bcal&searchon=names&exact=1"><img src="https://img.shields.io/badge/debian-9+-blue.svg?maxAge=2592000" alt="Debian Stretch+" /></a> -<a href="https://apps.fedoraproject.org/packages/bcal"><img src="https://img.shields.io/badge/fedora-27+-blue.svg?maxAge=2592000" alt="Fedora 27+" /></a> -<a href="https://packages.ubuntu.com/search?keywords=bcal&searchon=names&exact=1"><img src="https://img.shields.io/badge/ubuntu-17.04+-blue.svg?maxAge=2592000" alt="Ubuntu Zesty+" /></a> -<a href="https://launchpad.net/~twodopeshaggy/+archive/ubuntu/jarun/"><img src="https://img.shields.io/badge/ubuntu-PPA-blue.svg?maxAge=2592000" alt="Ubuntu PPA" /></a> -<p> - -<p align="center"> +<a href="https://repology.org/project/bcal/versions"><img src="https://repology.org/badge/tiny-repos/bcal.svg" alt="Availability"></a> <a href="https://travis-ci.org/jarun/bcal"><img src="https://img.shields.io/travis/jarun/bcal/master.svg" alt="Build Status" /></a> <a href="https://scan.coverity.com/projects/jarun-bcal"><img src="https://img.shields.io/coverity/scan/17148.svg" alt="Coverity Scan Build Status" /></a> <a href="https://github.com/jarun/bcal/blob/master/LICENSE"><img src="https://img.shields.io/badge/license-GPLv3-yellow.svg?maxAge=2592000" alt="License" /></a> @@ -20,16 +12,16 @@ <a href="https://asciinema.org/a/168719"><img src="https://asciinema.org/a/168719.png" alt="bcal_asciicast" width="600"/></a> </p> -`bcal` (*Byte CALculator*) is a REPL CLI utility for storage expressions, unit conversions or address calculations. If you can't calculate the hex address offset for (512 - 16) MiB, or the value when the 43<sup>rd</sup> bit of a 64-bit address is set mentally, `bcal` is for you. +`bcal` (*Byte CALculator*) is a REPL CLI utility for storage expression evaluation, unit conversion and address calculation. If you can't calculate the hex address offset for (512 - 16) MiB, or the value when the 43<sup>rd</sup> bit of a 64-bit address is set mentally, `bcal` is for you. -It has a [`bc`](https://www.gnu.org/software/bc/manual/html_mono/bc.html) mode for general-purpose numerical calculations. +It has a [`bc`](https://www.gnu.org/software/bc/manual/html_mono/bc.html) mode for general-purpose numerical calculations. Alternatively, it can also invoke [`calc`](http://www.isthe.com/chongo/tech/comp/calc/) which works better with expressions involving multiple bases. `bcal` follows Ubuntu's standard unit conversion and notation [policy](https://wiki.ubuntu.com/UnitsPolicy). Only 64-bit operating systems are supported. *Love smart and efficient utilities? Explore [my repositories](https://github.com/jarun?tab=repositories). Buy me a cup of coffee if they help you.* <p align="center"> -<a href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=RMLTQ76JSXJ4Q"><img src="https://img.shields.io/badge/PayPal-donate-green.svg" alt="Donate via PayPal!" /></a> +<a href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=RMLTQ76JSXJ4Q"><img src="https://img.shields.io/badge/PayPal-donate-1eb0fc.svg" alt="Donate via PayPal!" /></a> </p> ### Table of Contents @@ -50,8 +42,9 @@ ### Features +- REPL and single execution modes - evaluate arithmetic expressions involving storage units -- perform general purpose calculations (using bc) +- perform general purpose calculations (using bc or calc) - convert to IEC/SI standard data storage units - interactive mode with the last valid result stored for reuse - show the address in bytes @@ -65,19 +58,22 @@ #### Dependencies -`bcal` is written in C and depends on standard libc and libreadline. It invokes GNU `bc` for non-storage expressions. +`bcal` is written in C and depends on standard libc and libreadline. It invokes GNU `bc` or `calc` for non-storage expressions. + +To use `calc`: + + export BCAL_USE_CALC=1 #### From a package manager -- [AUR](https://aur.archlinux.org/packages/bcal/) (`yay -S bcal`) -- [Debian](https://packages.debian.org/search?keywords=bcal&searchon=names&exact=1) (`apt-get install bcal`) -- [Fedora](https://apps.fedoraproject.org/packages/bcal) (`dnf install bcal`) -- [Homebrew](http://formulae.brew.sh/formula/bcal) (`brew install bcal`) -- [NixOS](https://github.com/NixOS/nixpkgs/tree/master/pkgs/applications/science/math/bcal) (`nix-env -i bcal`) -- [Raspbian Testing](https://archive.raspbian.org/raspbian/pool/main/b/bcal/) (`apt-get install bcal`) -- [Ubuntu](https://packages.ubuntu.com/search?keywords=bcal&searchon=names&exact=1) (`apt-get install bcal`) -- [Ubuntu PPA](https://launchpad.net/~twodopeshaggy/+archive/ubuntu/jarun/) (`apt-get install bcal`) -- [Void Linux](https://github.com/void-linux/void-packages/tree/master/srcpkgs/bcal) (`xbps-install -S bcal`) +Install `bcal` from your package manager. If the version available is dated try an alternative installation method. + +<details><summary>Packaging status (expand)</summary> +<p> +<br> +<a href="https://repology.org/project/bcal/versions"><img src="https://repology.org/badge/vertical-allrepos/bcal.svg" alt="Packaging status"></a> +</p> +</details> #### Release packages @@ -90,7 +86,7 @@ Install to default location (`/usr/local`): $ make - $ sudo make install + $ sudo make strip install To uninstall, run: $ sudo make uninstall @@ -165,7 +161,7 @@ - sector size: 0x200 (512) - max heads per cylinder: 0x10 (16) - max sectors per track: 0x3f (63) -- **bc variables**: `scale` = 10, `ibase` = 10. `last` and `r` are synced when toggling `bc` mode. `bc` is not called in minimal output mode. +- **bc variables**: `scale` = 10, `ibase` = 10. `r` is synced and can be used in expressions. `bc` is not called in minimal output mode. ### Examples diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/bcal-2.1/bcal.1 new/bcal-2.2/bcal.1 --- old/bcal-2.1/bcal.1 2018-12-11 16:12:41.000000000 +0100 +++ new/bcal-2.2/bcal.1 2020-01-07 15:45:52.000000000 +0100 @@ -1,11 +1,17 @@ -.TH "BCAL" "1" "11 Dec 2018" "Version 2.1" "User Commands" +.TH "BCAL" "1" "07 Jan 2020" "Version 2.2" "User Commands" .SH NAME bcal \- Storage expression calculator. .SH SYNOPSIS .B bcal [-c N] [-f loc] [-s bytes] [expr] [N [unit]] [-b [expr]] [-m] [-d] [-h] .SH DESCRIPTION .B bcal -(Byte CALculator) is a command-line utility to help with numerical calculations and expressions involving data storage units, addressing, base conversion etc. It invokes GNU \fBbc\fR for non-storage expressions. +(Byte CALculator) is a command-line utility to help with numerical calculations and expressions involving data storage units, addressing, base conversion etc. +.PP +It invokes GNU \fBbc\fR for non-storage expressions. Alternatively, it can also invoke \fBcalc\fR (\fIhttp://www.isthe.com/chongo/tech/comp/calc/\fR) which works better with expressions involving multiple bases. To use \fBcalc\fR: +.PP +.EX +.B export BCAL_USE_CALC=1 +.EE .PP \fBbcal\fR follows Ubuntu's standard unit conversion and notation policy: .br @@ -14,7 +20,7 @@ .SH FEATURES .PP * evaluate arithmetic expressions involving storage units - * perform general purpose calculations (using bc) + * perform general purpose calculations (using bc or calc) * convert to IEC/SI standard data storage units * interactive mode with the last valid result stored for reuse * show the address in bytes @@ -63,7 +69,7 @@ - max sectors per track: 0x3f (63) .PP .IP 10. 4 -\fBbc variables\fR: \fIscale\fR = 10, \fIibase\fR = 10. \fIlast\fR and \fIr\fR are synced when toggling \fIbc\fR mode. \fIbc\fR is not called in minimal output mode. +\fBbc variables\fR: \fIscale\fR = 10, \fIibase\fR = 10. \fBr\fR is synced and can be used in expressions. \fBbc\fR is not called in minimal output mode. To use \fBcalc\fR instead of \fBbc\fR, \fIexport BCAL_USE_CALC=1\fR. .SH OPTIONS .TP .BI "-c=" N @@ -76,7 +82,7 @@ Sector size in bytes. Default value is 512. .TP .BI "-b=" [expr] -Start in \fIbc\fR mode. If expression is provided, evaluate in \fIbc\fR and quit. +Start in \fBbc\fR mode. If expression is provided, evaluate in \fBbc\fR and quit. .TP .BI "-m" Show minimal output (e.g. decimal bytes). @@ -89,7 +95,7 @@ .SH PROMPT KEYS .TP .BI "b" -Toggle \fIbc\fR mode. +Toggle \fBbc\fR mode. .TP .BI "r" Show result from last operation. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/bcal-2.1/packagecore.yaml new/bcal-2.2/packagecore.yaml --- old/bcal-2.1/packagecore.yaml 2018-12-11 16:12:41.000000000 +0100 +++ new/bcal-2.2/packagecore.yaml 2020-01-07 15:45:52.000000000 +0100 @@ -13,29 +13,22 @@ - gcc deps: - readline - container: "base/archlinux" - centos7.1: + container: "archlinux/base" + centos7.5: builddeps: - make - gcc - readline-devel deps: - readline - centos7.2: + centos7.6: builddeps: - make - gcc - readline-devel deps: - readline - centos7.3: - builddeps: - - make - - gcc - - readline-devel - deps: - - readline - centos7.4: + centos8.0: builddeps: - make - gcc @@ -49,34 +42,13 @@ - libreadline-dev deps: - readline-common - fedora25: - builddeps: - - make - - gcc - - readline-devel - deps: - - readline - fedora26: - builddeps: - - make - - gcc - - readline-devel - deps: - - readline - fedora27: - builddeps: - - make - - gcc - - readline-devel - deps: - - readline - fedora28: + debian10: builddeps: - make - gcc - - readline-devel + - libreadline-dev deps: - - readline + - readline-common fedora29: builddeps: - make @@ -84,34 +56,27 @@ - readline-devel deps: - readline - opensuse42.1: + fedora30: builddeps: - make - gcc - readline-devel deps: - readline - opensuse42.2: + fedora31: builddeps: - make - gcc - readline-devel deps: - readline - opensuse42.3: + opensuse15.1: builddeps: - make - gcc - readline-devel deps: - readline - ubuntu14.04: - builddeps: - - make - - gcc - - libreadline6-dev - deps: - - libreadline6 ubuntu16.04: builddeps: - make diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/bcal-2.1/src/bcal.c new/bcal-2.2/src/bcal.c --- old/bcal-2.1/src/bcal.c 2018-12-11 16:12:41.000000000 +0100 +++ new/bcal-2.2/src/bcal.c 2020-01-07 15:45:52.000000000 +0100 @@ -66,11 +66,12 @@ uchar bcmode : 1; uchar minimal : 1; uchar repl : 1; - uchar rsvd : 3; /* Reserved for future usage */ + uchar calc : 1; + uchar rsvd : 2; /* Reserved for future usage */ uchar loglvl : 2; } settings; -static char *VERSION = "2.1"; +static char *VERSION = "2.2"; static char *units[] = {"b", "kib", "mib", "gib", "tib", "kb", "mb", "gb", "tb"}; static char *logarr[] = {"ERROR", "WARNING", "INFO", "DEBUG"}; @@ -83,7 +84,7 @@ static char float_buf[FLOAT_BUF_LEN]; static Data lastres = {"\0", 0}; -static settings cfg = {0, 0, 0, 0, INFO}; +static settings cfg = {0, 0, 0, 0, 0, INFO}; static void debug_log(const char *func, int level, const char *format, ...) { @@ -171,8 +172,10 @@ static int try_bc(char *expr) { pid_t pid; - int pipe_pc[2], pipe_cp[2], ret; - size_t len, count = 0; + int pipe_pc[2], pipe_cp[2]; + size_t len; + ssize_t ret; + char *ptr = cfg.calc ? "calc" : "bc"; if (!expr) { if (curexpr) @@ -205,24 +208,26 @@ dup2(pipe_cp[1], STDOUT_FILENO); // Give stdout to parent dup2(pipe_cp[1], STDERR_FILENO); // Give stderr to parent - ret = execlp("bc", "bc", "-q", (char*) NULL); + ret = execlp(ptr, ptr, (char*) NULL); log(ERROR, "execlp() failed!\n"); exit(ret); } - /* parent */ - if (write(pipe_pc[1], "scale=10\n", 9) != 9) { - log(ERROR, "write(1)! [%s]\n", strerror(errno)); - exit(-1); + if (!cfg.calc) { + /* parent */ + if (write(pipe_pc[1], "scale=10\n", 9) != 9) { + log(ERROR, "write(1)! [%s]\n", strerror(errno)); + exit(-1); + } } - if (write(pipe_pc[1], "last=", 5) != 5) { + if (write(pipe_pc[1], "r=", 2) != 2) { log(ERROR, "write(2)! [%s]\n", strerror(errno)); exit(-1); } if (lastres.p[0]) { - ret = strlen(lastres.p); + ret = (ssize_t)strlen(lastres.p); if (write(pipe_pc[1], lastres.p, ret) != ret) { log(ERROR, "write(3)! [%s]\n", strerror(errno)); exit(-1); @@ -239,7 +244,7 @@ exit(-1); } - ret = strlen(expr); + ret = (ssize_t)strlen(expr); if (write(pipe_pc[1], expr, ret) != ret) { log(ERROR, "write(6)! [%s]\n", strerror(errno)); exit(-1); @@ -261,14 +266,21 @@ buffer[ret] = '\0'; if (buffer[0] != '(') { - printf("%s", buffer); - len = bstrlcpy(lastres.p, buffer, NUM_LEN); + ptr = buffer; + while (isspace(*ptr)) /* calc results have space before them */ + ++ptr; + + printf("%s", ptr); + len = bstrlcpy(lastres.p, ptr, NUM_LEN); /* remove newline appended at the end of result by bc */ (len >= 2) ? (len -= 2) : (len = 0); lastres.p[len] = '\0'; +#ifdef TRIM_DECIMAL /* Trim the decimal part, if any */ + size_t count = 0; + while (count < len) { if (lastres.p[count] == '.') { lastres.p[count] = '\0'; @@ -277,6 +289,7 @@ ++count; } +#endif lastres.unit = 0; log(DEBUG, "result: %s %d\n", lastres.p, lastres.unit); return 0; @@ -1162,7 +1175,7 @@ static int bstricmp(const char *s1, const char *s2) { - while (*s1 && (tolower(*s1) == tolower(*s2))) { + while ((int)*s1 && (tolower((int)*s1) == tolower((int)*s2))) { ++s1; ++s2; } @@ -1430,7 +1443,7 @@ dequeue(front, rear, &arg); /* Check if arg is an operator */ - if (strlen(arg.p) == 1 && !isdigit(arg.p[0])) { + if (strlen(arg.p) == 1 && !isdigit((int)arg.p[0])) { pop(&est, &raw_b); pop(&est, &raw_a); @@ -1609,7 +1622,7 @@ } /* Check if a char is operator or not */ -static int isoperator(char c) +static int isoperator(int c) { switch (c) { case '+': @@ -1649,16 +1662,16 @@ if (!s || !*s) return; - int len = strlen(s) - 1; + int len = (int)strlen(s) - 1; if (s[len] == '\n') --len; - while (len >= 0 && (isspace(s[len]) || s[len] == '\"' || s[len] == '\'')) + while (len >= 0 && (isspace((int)s[len]) || s[len] == '\"' || s[len] == '\'')) --len; s[len + 1] = '\0'; len = 0; - while (s[len] && (isspace(s[len]) || s[len] == '\"' || s[len] == '\'')) + while (s[len] && (isspace((int)s[len]) || s[len] == '\"' || s[len] == '\'')) ++len; if (len) { @@ -1678,7 +1691,7 @@ while (*s != '\0') { /* We should not combine 0xn b*/ - if (!isspace(*s) || (*(s + 1) == 'b')) { + if (!isspace((int)*s) || (*(s + 1) == 'b')) { *p = *s; ++p; } @@ -1726,17 +1739,17 @@ return NULL; } - if (isoperator(exp[i]) && isalpha(exp[i + 1]) && (exp[i + 1] != 'r')) { + if (isoperator((int)exp[i]) && isalpha((int)exp[i + 1]) && (exp[i + 1] != 'r')) { log(ERROR, "invalid expression\n"); free(parsed); return NULL; } - if ((isdigit(exp[i]) && isoperator(exp[i + 1])) || - (isoperator(exp[i]) && (isdigit(exp[i + 1]) || - isoperator(exp[i + 1]))) || - (isalpha(exp[i]) && isoperator(exp[i + 1])) || - (isoperator(exp[i]) && (exp[i + 1] == 'r'))) { + if ((isdigit((int)exp[i]) && isoperator((int)exp[i + 1])) || + (isoperator((int)exp[i]) && (isdigit((int)exp[i + 1]) || + isoperator((int)exp[i + 1]))) || + (isalpha((int)exp[i]) && isoperator((int)exp[i + 1])) || + (isoperator((int)exp[i]) && ((int)exp[i + 1] == 'r'))) { if (exp[i] == '<' || exp[i] == '>') { /* handle shift operators << and >> */ if (prev != exp[i] && exp[i] != exp[i + 1]) { log(ERROR, "invalid operator %c\n", exp[i]); @@ -1805,10 +1818,10 @@ } if (!unit) { - int unitchars = 0, len = strlen(value); + int unitchars = 0, len = (int)strlen(value); while (len) { - if (!isalpha(value[len - 1])) + if (!isalpha((int)value[len - 1])) break; ++unitchars; @@ -1923,7 +1936,8 @@ char *expr = fixexpr(exp, &ret); /* Make parsing compatible */ char *ptr; - log(DEBUG, "expr: %s\n", expr); + if (expr) + log(DEBUG, "expr: %s\n", expr); if (expr == NULL) { if (ret) @@ -2014,6 +2028,9 @@ int opt = 0, operation = 0; ulong sectorsz = SECTOR_SIZE; + if (getenv("BCAL_USE_CALC")) + cfg.calc = TRUE; + opterr = 0; rl_bind_key('\t', rl_insert); @@ -2029,7 +2046,7 @@ case 'f': operation = 1; - if (tolower(*optarg) == 'c') { + if (tolower((int)*optarg) == 'c') { maxuint_t lba = 0; if (chs2lba(optarg + 1, &lba)) { @@ -2038,7 +2055,7 @@ printhex_u128(lba); printf("\n\n"); } - } else if (tolower(*optarg) == 'l') { + } else if (tolower((int)*optarg) == 'l') { t_chs chs; if (lba2chs(optarg + 1, &chs)) { @@ -2062,7 +2079,10 @@ break; case 'b': cfg.bcmode = 1; - strncpy(prompt, "bc> ", 5); + if (cfg.calc) + strncpy(prompt, "calc> ", 7); + else + strncpy(prompt, "bc> ", 5); break; case 'd': cfg.loglvl = DEBUG; @@ -2137,8 +2157,12 @@ case 'b': cfg.bcmode ^= 1; if (cfg.bcmode) { - printf("bc vars: scale = 10, ibase = 10, last = r\n"); - strncpy(prompt, "bc> ", 5); + if (cfg.calc) + strncpy(prompt, "calc> ", 7); + else { + printf("bc vars: scale = 10, ibase = 10\n"); + strncpy(prompt, "bc> ", 5); + } } else strncpy(prompt, "bcal> ", 7);
