lcn2 / calc

C-style arbitrary precision calculator
http://www.isthe.com/chongo/tech/comp/calc/index.html
Other
346 stars 52 forks source link

lib_calc.c requires CUSTOM #22

Closed barsnick closed 3 years ago

barsnick commented 3 years ago

HI, version 2.12.8.0/1, commit 91991bb729a3bfd883535a9c9715851d29a9c3aa introduced code which relies in CUSTOM to be set:

gcc  -DCALC_SRC -UCUSTOM -Wall  -march=native   -fPIC -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m32 -march=pentium4 -fasync
hronous-unwind-tables   -c -o lib_calc.o lib_calc.c                                                                                                                                   
lib_calc.c: In function 'initenv':                                                                                                                                                    
lib_calc.c:573: error: 'CUSTOMHELPDIR' undeclared (first use in this function)                                                                                                        
lib_calc.c:573: error: (Each undeclared identifier is reported only once                                                                                                              
lib_calc.c:573: error: for each function it appears in.)                                                                                                                              
make: *** [lib_calc.o] Error 1                                                                                                                                                        

For it to compile without CUSTOM, the block of code beginning at https://github.com/lcn2/calc/blob/91991bb729a3bfd883535a9c9715851d29a9c3aa/lib_calc.c#L568 needs to be protected by #if defined(CUSTOM).

I won't create a PR for a simple fix - here's my patch:

--- calc-2.12.8.1/lib_calc.c    2021-02-13 01:06:04.000000000 +0100
+++ calc-2.12.8.1-nocustom/lib_calc.c   2021-02-20 13:03:07.000000000 +0100
@@ -565,6 +565,7 @@
                calc_helpdir = HELPDIR;
        }

+#if defined(CUSTOM)
        /* determine the $CALCCUSTOMHELP value */
        c = (no_env ? NULL : getenv(CALCCUSTOMHELP));
        calc_customhelpdir = (c ? strdup(c) : NULL);
@@ -572,6 +573,7 @@
                /* will use /usr/local/share/calc/custhelp */
                calc_customhelpdir = CUSTOMHELPDIR;
        }
+#endif
 }

"Works for me." Thanks.

lcn2 commented 3 years ago

Thank you and fixed in calc v2.12.8.2.