mirror of
https://github.com/lcn2/calc.git
synced 2025-08-16 01:03:29 +03:00
changed C source to use C booleans with backward compatibility
Fix "Under source code control" date for new version.h file. Sorted the order of symbols printed by "make env". Test if <stdbool.h> exists and set HAVE_STDBOOL_H accordingly in have_stdbool.h. Added HAVE_STDBOOL_H to allow one to force this value. Added "bool.h" include file to support use of boolean symbols, true and false for pre-c99 C compilers. The "bool.h" include file defines TRUE as true, FALSE as false, and BOOL as bool: for backward compatibility. The sign in a ZVALUE is now of type SIGN, whcih is either SB32 when CALC2_COMPAT is defined, or a bool. Replaced in C source, TRUE with true, FALSE with false, and BOOL with bool.
This commit is contained in:
22
zio.c
22
zio.c
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* zio - scanf and printf routines for arbitrary precision integers
|
||||
*
|
||||
* Copyright (C) 1999-2007,2021,2022 David I. Bell
|
||||
* Copyright (C) 1999-2007,2021-2023 David I. Bell
|
||||
*
|
||||
* Calc is open software; you can redistribute it and/or modify it under
|
||||
* the terms of the version 2.1 of the GNU Lesser General Public License
|
||||
@@ -58,14 +58,14 @@ struct iostate {
|
||||
char *outbuf; /* output string buffer (if any) */
|
||||
size_t outbufsize; /* current size of string buffer */
|
||||
size_t outbufused; /* space used in string buffer */
|
||||
BOOL outputisstring; /* TRUE if output is to string buffer */
|
||||
bool outputisstring; /* true if output is to string buffer */
|
||||
};
|
||||
|
||||
|
||||
STATIC IOSTATE *oldiostates = NULL; /* list of saved output states */
|
||||
STATIC FILE *outfp = NULL; /* file unit for output */
|
||||
STATIC char *outbuf = NULL; /* current diverted buffer */
|
||||
STATIC BOOL outputisstring = FALSE;
|
||||
STATIC bool outputisstring = false;
|
||||
STATIC size_t outbufsize;
|
||||
STATIC size_t outbufused;
|
||||
|
||||
@@ -232,7 +232,7 @@ math_divertio(void)
|
||||
not_reached();
|
||||
}
|
||||
outbufsize = OUTBUFSIZE;
|
||||
outputisstring = TRUE;
|
||||
outputisstring = true;
|
||||
oldiostates = sp;
|
||||
}
|
||||
|
||||
@@ -602,8 +602,8 @@ zprintval(ZVALUE z, long decimals, long width)
|
||||
long leadspaces; /* number of leading spaces to print */
|
||||
long putpoint; /* digits until print decimal point */
|
||||
long digits; /* number of digits of raw number */
|
||||
BOOL output; /* TRUE if have output something */
|
||||
BOOL neg; /* TRUE if negative */
|
||||
bool output; /* true if have output something */
|
||||
bool neg; /* true if negative */
|
||||
ZVALUE quo, rem; /* quotient and remainder */
|
||||
ZVALUE leftnums[32]; /* left parts of the number */
|
||||
ZVALUE rightnums[32]; /* right parts of the number */
|
||||
@@ -642,7 +642,7 @@ zprintval(ZVALUE z, long decimals, long width)
|
||||
* we visit left nodes first. We do the needed recursion in line.
|
||||
*/
|
||||
digits = 1;
|
||||
output = FALSE;
|
||||
output = false;
|
||||
n = 0;
|
||||
putpoint = 0;
|
||||
rightnums[0].len = 0;
|
||||
@@ -660,7 +660,7 @@ zprintval(ZVALUE z, long decimals, long width)
|
||||
i = (long)(leftnums[n].v[0]);
|
||||
if (output || i || (n == 0)) {
|
||||
if (!output) {
|
||||
output = TRUE;
|
||||
output = true;
|
||||
if (decimals < digits)
|
||||
leadspaces -= digits;
|
||||
else
|
||||
@@ -711,15 +711,15 @@ str2z(char *s, ZVALUE *res)
|
||||
{
|
||||
ZVALUE z, ztmp, digit;
|
||||
HALF digval;
|
||||
BOOL minus;
|
||||
bool minus;
|
||||
long shift;
|
||||
|
||||
minus = FALSE;
|
||||
minus = false;
|
||||
shift = 0;
|
||||
if (*s == '+')
|
||||
s++;
|
||||
else if (*s == '-') {
|
||||
minus = TRUE;
|
||||
minus = true;
|
||||
s++;
|
||||
}
|
||||
if (*s == '0') { /* possibly hex, octal, or binary */
|
||||
|
Reference in New Issue
Block a user