Checkpoint on calc version 2.12.8.0

Fixed a mistake in "help intro" where some inserted text
    changed the value of "." and thus made the next result
    incorrect.

    Clarified in "help factor" that 1 is returned if no
    factor below the limit was found.

    Removed Makefile variable ${MAKEFILE_REV}.

    The missing cscript/square.calc file has been restored.

    Fixed compiler errors and warnings related to GCC.
    In particular, gcc/9.3.1 and gcc/10.2.1 now compile
    calc without any compiler errors or warnings,
    even with -Werror -Wextra -pedantic.

    To print out information about the calc compliation
    environment, we added the following make rule:

	make calcinfo

    Improved how 'make debug' operates.

    Moved help/contrib to CONTRIB-CODE.  The help/contrib file
    is now build from a copy of CONTRIB-CODE.

    Created a new calc bug report Email address.  Created a new calc
    question Email address.  Created a new calc contribution Email
    address.  See the BUGS file for details.

    Added "help questions" to print the QUESIONS help file.

    If the environment variable $CALCHELP is defined and is non-empty,
    then calc help files will be in the direcgory by the $CALCHISTFILE
    environment variable.

    If the environment variable $CALCCUSTOMHELP is defined and is
    non-empty, then custom calc help files will be in the direcgory
    by the $CALCCUSTOMHELP environment variable.

    The calc-tester mailing list has been retired.  See:

	* How to submit a calc bug report:

	    http://www.isthe.com/chongo/tech/comp/calc/calc-bugrept.html

	* How to contribute code to calc:

	    http://www.isthe.com/chongo/tech/comp/calc/calc-contrib.html

	* How to submit a question about calc:

	    http://www.isthe.com/chongo/tech/comp/calc/calc-question.html
This commit is contained in:
Landon Curt Noll
2021-02-12 15:50:39 -08:00
parent 71a116ca6f
commit 91991bb729
33 changed files with 804 additions and 645 deletions

52
help.c
View File

@@ -32,6 +32,7 @@
#include "calc.h"
#include "conf.h"
#include "lib_calc.h"
#include "have_unistd.h"
#if defined(HAVE_UNISTD_H)
@@ -78,6 +79,7 @@ STATIC struct help_alias {
{"cd", "command"},
{"show", "command"},
{"stdlib", "resource"},
{"question", "questions"},
{NULL, NULL}
};
@@ -246,22 +248,13 @@ givehelp(char *type)
/*
* open the helpfile (looking in HELPDIR first)
*/
#if defined(CUSTOM)
if (sizeof(CUSTOMHELPDIR) > sizeof(HELPDIR)) {
snprintf_len = sizeof(CUSTOMHELPDIR)+1+strlen(type) + 1;
} else {
snprintf_len = sizeof(HELPDIR)+1+strlen(type) + 1;
}
snprintf_len = strlen(calc_helpdir)+1+strlen(type) + 1;
helppath = (char *)malloc(snprintf_len+1);
#else /* CUSTOM */
snprintf_len = sizeof(HELPDIR)+1+strlen(type) + 1;
helppath = (char *)malloc(snprintf_len+1);
#endif /* CUSTOM */
if (helppath == NULL) {
fprintf(stderr, "malloc failure in givehelp()\n");
fprintf(stderr, "malloc failure in givehelp #0\n");
return;
}
snprintf(helppath, snprintf_len, "%s/%s", HELPDIR, type);
snprintf(helppath, snprintf_len, "%s/%s", calc_helpdir, type);
helppath[snprintf_len] = '\0'; /* paranoia */
stream = fopen(helppath, "r");
if (stream != NULL) {
@@ -277,22 +270,30 @@ givehelp(char *type)
* open the helpfile (looking in CUSTOMHELPDIR last)
*/
} else {
char *cust_helppath; /* path to the custom help file */
size_t cust_snprintf_len; /* malloced custom snprintf buf len */
snprintf(helppath, snprintf_len, "%s/%s", CUSTOMHELPDIR, type);
helppath[snprintf_len] = '\0'; /* paranoia */
stream = fopen(helppath, "r");
if (stream == NULL) {
cust_snprintf_len = strlen(calc_customhelpdir)+1+strlen(type) + 1;
cust_helppath = (char *)malloc(cust_snprintf_len+1);
if (cust_helppath == NULL) {
fprintf(stderr, "malloc failure for givehelp #1\n");
return;
}
snprintf(cust_helppath, cust_snprintf_len,
"%s/%s", calc_customhelpdir, type);
cust_helppath[cust_snprintf_len] = '\0'; /* paranoia */
stream = fopen(cust_helppath, "r");
if (stream != NULL) {
/* no such help file */
fprintf(stderr,
"%s: no such help file, try: help help\n",
type);
} else {
/*
* we have the help file open, now display it
*/
page_file(stream);
(void) fclose(stream);
}
free(cust_helppath);
cust_helppath = NULL;
/* we have the help file open, now display it */
page_file(stream);
(void) fclose(stream);
}
#endif /* CUSTOM */
}
@@ -300,5 +301,6 @@ givehelp(char *type)
* cleanup
*/
free(helppath);
helppath = NULL;
return;
}