]> git.pld-linux.org Git - packages/dalc.git/blob - dalc-ac_am.patch
- massive change ( validate errors warrings from desktop-file-validate)
[packages/dalc.git] / dalc-ac_am.patch
1 diff -Nru dalc-0.1/AUTHORS dalc-0.1.new/AUTHORS
2 --- dalc-0.1/AUTHORS    Thu Jan  1 01:00:00 1970
3 +++ dalc-0.1.new/AUTHORS        Fri Nov 24 16:46:10 2000
4 @@ -0,0 +1 @@
5
6 \ No newline at end of file
7 diff -Nru dalc-0.1/ChangeLog dalc-0.1.new/ChangeLog
8 --- dalc-0.1/ChangeLog  Thu Jan  1 01:00:00 1970
9 +++ dalc-0.1.new/ChangeLog      Fri Nov 24 16:46:08 2000
10 @@ -0,0 +1 @@
11
12 \ No newline at end of file
13 diff -Nru dalc-0.1/INSTALL dalc-0.1.new/INSTALL
14 --- dalc-0.1/INSTALL    Thu Jan  1 01:00:00 1970
15 +++ dalc-0.1.new/INSTALL        Fri Nov 24 16:46:12 2000
16 @@ -0,0 +1 @@
17
18 \ No newline at end of file
19 diff -Nru dalc-0.1/Makefile dalc-0.1.new/Makefile
20 --- dalc-0.1/Makefile   Thu Dec  9 06:17:36 1999
21 +++ dalc-0.1.new/Makefile       Thu Jan  1 01:00:00 1970
22 @@ -1,27 +0,0 @@
23 -CPP            =g++
24 -MANFILES       =dalc.1
25 -MANDIR         =/usr/local/man/man1
26 -BINARIES       =dalc
27 -BINDIR         =/usr/local/bin
28 -CFLAGS         =-O3 -Wall -m486 -DVIEWER=\"xv\" -DCONVERTER=\"ppmtogif\"
29 -LDFLAGS                =-L/usr/X11R6/lib
30 -LIBS           =-lm -lncurses -lmenu
31 -INSTALL                =install -o root -g root
32 -
33 -.SUFFIXES:     .C
34 -
35 -.C.o:
36 -               g++ $(CFLAGS) -o $*.o -c $*.C
37 -
38 -all:           $(BINARIES)
39 -
40 -dalc:          dalc.o dalexpr.o
41 -               g++ $(LIBS) $(LDFLAGS) -o $@ $^
42 -
43 -install:
44 -               $(INSTALL) -m 0755 $(BINARIES) $(BINDIR)
45 -               $(INSTALL) -m 0644 $(MANFILES) $(MANDIR)
46 -
47 -clean:         
48 -               rm -f *.o
49 -               rm -f $(BINARIES)
50 diff -Nru dalc-0.1/Makefile.am dalc-0.1.new/Makefile.am
51 --- dalc-0.1/Makefile.am        Thu Jan  1 01:00:00 1970
52 +++ dalc-0.1.new/Makefile.am    Fri Nov 24 16:38:02 2000
53 @@ -0,0 +1,9 @@
54 +
55 +INCLUDES = $(CURSES_INCLUDEDIR) \
56 +       -DVIEWER=\"xv\" -DCONVERTER=\"ppmtogif\"
57 +
58 +bin_PROGRAMS = dalc
59 +
60 +dalc_SOURCES = dalc.cc dalexpr.cc dalexpr.h
61 +
62 +man_MANS = dalc.1
63 diff -Nru dalc-0.1/NEWS dalc-0.1.new/NEWS
64 --- dalc-0.1/NEWS       Thu Jan  1 01:00:00 1970
65 +++ dalc-0.1.new/NEWS   Fri Nov 24 16:46:00 2000
66 @@ -0,0 +1 @@
67
68 \ No newline at end of file
69 diff -Nru dalc-0.1/README dalc-0.1.new/README
70 --- dalc-0.1/README     Thu Jan  1 01:00:00 1970
71 +++ dalc-0.1.new/README Fri Nov 24 16:45:52 2000
72 @@ -0,0 +1 @@
73
74 \ No newline at end of file
75 diff -Nru dalc-0.1/acconfig.h dalc-0.1.new/acconfig.h
76 --- dalc-0.1/acconfig.h Thu Jan  1 01:00:00 1970
77 +++ dalc-0.1.new/acconfig.h     Fri Nov 24 16:32:42 2000
78 @@ -0,0 +1,29 @@
79 +/* Define if you want to turn on SCO-specific code */
80 +#undef SCO_FLAVOR
81 +
82 +/* Found some version of curses that we're going to use */
83 +#undef HAS_CURSES
84 +
85 +/* Are you using other type of curses? */
86 +#undef OTHER_CURSES
87 +
88 +/* Use SunOS SysV curses? */
89 +#undef USE_SUNOS_CURSES
90 +
91 +/* Use old BSD curses? */
92 +#undef USE_BSD_CURSES
93 +
94 +/* Use SystemV curses? */
95 +#undef USE_SYSV_CURSES
96 +
97 +/* Use Ncurses? */
98 +#undef USE_NCURSES
99 +
100 +/* If you Curses does not have color define this one */
101 +#undef NO_COLOR_CURSES
102 +
103 +/* If Slang library should use termcap */
104 +#undef USE_TERMCAP
105 +
106 +/* Version of ncurses */
107 +#undef NCURSES_970530
108 diff -Nru dalc-0.1/acinclude.m4 dalc-0.1.new/acinclude.m4
109 --- dalc-0.1/acinclude.m4       Thu Jan  1 01:00:00 1970
110 +++ dalc-0.1.new/acinclude.m4   Thu Aug  3 00:26:45 2000
111 @@ -0,0 +1,318 @@
112 +dnl Curses detection: Munged from Midnight Commander's configure.in
113 +dnl
114 +dnl What it does:
115 +dnl =============
116 +dnl
117 +dnl - Determine which version of curses is installed on your system
118 +dnl   and set the -I/-L/-l compiler entries and add a few preprocessor
119 +dnl   symbols 
120 +dnl - Do an AC_SUBST on the CURSES_INCLUDEDIR and CURSES_LIBS so that
121 +dnl   @CURSES_INCLUDEDIR@ and @CURSES_LIBS@ will be available in
122 +dnl   Makefile.in's
123 +dnl - Modify the following configure variables (these are the only
124 +dnl   curses.m4 variables you can access from within configure.in)
125 +dnl   CURSES_INCLUDEDIR - contains -I's and possibly -DRENAMED_CURSES if
126 +dnl                       an ncurses.h that's been renamed to curses.h
127 +dnl                       is found.
128 +dnl   CURSES_LIBS       - sets -L and -l's appropriately
129 +dnl   CFLAGS            - if --with-sco, add -D_SVID3 
130 +dnl   has_curses        - exports result of tests to rest of configure
131 +dnl
132 +dnl Usage:
133 +dnl ======
134 +dnl 1) Add lines indicated below to acconfig.h
135 +dnl 2) call AC_CHECK_CURSES after AC_PROG_CC in your configure.in
136 +dnl 3) Instead of #include <curses.h> you should use the following to
137 +dnl    properly locate ncurses or curses header file
138 +dnl
139 +dnl    #if defined(USE_NCURSES) && !defined(RENAMED_NCURSES)
140 +dnl    #include <ncurses.h>
141 +dnl    #else
142 +dnl    #include <curses.h>
143 +dnl    #endif
144 +dnl
145 +dnl 4) Make sure to add @CURSES_INCLUDEDIR@ to your preprocessor flags
146 +dnl 5) Make sure to add @CURSES_LIBS@ to your linker flags or LIBS
147 +dnl
148 +dnl Notes with automake:
149 +dnl - call AM_CONDITIONAL(HAS_CURSES, test "$has_curses" = true) from
150 +dnl   configure.in
151 +dnl - your Makefile.am can look something like this
152 +dnl   -----------------------------------------------
153 +dnl   INCLUDES= blah blah blah $(CURSES_INCLUDEDIR) 
154 +dnl   if HAS_CURSES
155 +dnl   CURSES_TARGETS=name_of_curses_prog
156 +dnl   endif
157 +dnl   bin_PROGRAMS = other_programs $(CURSES_TARGETS)
158 +dnl   other_programs_SOURCES = blah blah blah
159 +dnl   name_of_curses_prog_SOURCES = blah blah blah
160 +dnl   other_programs_LDADD = blah
161 +dnl   name_of_curses_prog_LDADD = blah $(CURSES_LIBS)
162 +dnl   -----------------------------------------------
163 +dnl
164 +dnl
165 +dnl The following lines should be added to acconfig.h:
166 +dnl ==================================================
167 +dnl
168 +dnl /*=== Curses version detection defines ===*/
169 +dnl /* Found some version of curses that we're going to use */
170 +dnl #undef HAS_CURSES
171 +dnl    
172 +dnl /* Use SunOS SysV curses? */
173 +dnl #undef USE_SUNOS_CURSES
174 +dnl 
175 +dnl /* Use old BSD curses - not used right now */
176 +dnl #undef USE_BSD_CURSES
177 +dnl 
178 +dnl /* Use SystemV curses? */
179 +dnl #undef USE_SYSV_CURSES
180 +dnl 
181 +dnl /* Use Ncurses? */
182 +dnl #undef USE_NCURSES
183 +dnl 
184 +dnl /* If you Curses does not have color define this one */
185 +dnl #undef NO_COLOR_CURSES
186 +dnl 
187 +dnl /* Define if you want to turn on SCO-specific code */
188 +dnl #undef SCO_FLAVOR
189 +dnl 
190 +dnl /* Set to reflect version of ncurses *
191 +dnl  *   0 = version 1.*
192 +dnl  *   1 = version 1.9.9g
193 +dnl  *   2 = version 4.0/4.1 */
194 +dnl #undef NCURSES_970530
195 +dnl
196 +dnl /*=== End new stuff for acconfig.h ===*/
197 +dnl 
198 +
199 +
200 +AC_DEFUN(AC_CHECK_CURSES,[
201 +       search_ncurses=true
202 +       screen_manager=""
203 +       has_curses=false
204 +
205 +       CFLAGS=${CFLAGS--O}
206 +
207 +       AC_SUBST(CURSES_LIBS)
208 +       AC_SUBST(CURSES_INCLUDEDIR)
209 +
210 +       AC_ARG_WITH(sco,
211 +         [  --with-sco              Use this to turn on SCO-specific code],[
212 +         if test x$withval = xyes; then
213 +               AC_DEFINE(SCO_FLAVOR)
214 +               CFLAGS="$CFLAGS -D_SVID3"
215 +         fi
216 +       ])
217 +
218 +       AC_ARG_WITH(sunos-curses,
219 +         [  --with-sunos-curses     Used to force SunOS 4.x curses],[
220 +         if test x$withval = xyes; then
221 +               AC_USE_SUNOS_CURSES
222 +         fi
223 +       ])
224 +
225 +       AC_ARG_WITH(osf1-curses,
226 +         [  --with-osf1-curses      Used to force OSF/1 curses],[
227 +         if test x$withval = xyes; then
228 +               AC_USE_OSF1_CURSES
229 +         fi
230 +       ])
231 +
232 +       AC_ARG_WITH(vcurses,
233 +         [  --with-vcurses[=incdir] Used to force SysV curses],
234 +         if test x$withval != xyes; then
235 +               CURSES_INCLUDEDIR="-I$withval"
236 +         fi
237 +         AC_USE_SYSV_CURSES
238 +       )
239 +
240 +       AC_ARG_WITH(ncurses,
241 +         [  --with-ncurses[=dir]  Compile with ncurses/locate base dir],
242 +         if test x$withval = xno ; then
243 +               search_ncurses=false
244 +         elif test x$withval != xyes ; then
245 +               CURSES_LIBS="$LIBS -L$withval/lib -lncurses"
246 +               CURSES_INCLUDEDIR="-I$withval/include"
247 +               search_ncurses=false
248 +               screen_manager="ncurses"
249 +               AC_DEFINE(USE_NCURSES)
250 +               AC_DEFINE(HAS_CURSES)
251 +               has_curses=true
252 +         fi
253 +       )
254 +
255 +       if $search_ncurses
256 +       then
257 +               AC_SEARCH_NCURSES()
258 +       fi
259 +
260 +
261 +])
262 +
263 +
264 +AC_DEFUN(AC_USE_SUNOS_CURSES, [
265 +       search_ncurses=false
266 +       screen_manager="SunOS 4.x /usr/5include curses"
267 +       AC_MSG_RESULT(Using SunOS 4.x /usr/5include curses)
268 +       AC_DEFINE(USE_SUNOS_CURSES)
269 +       AC_DEFINE(HAS_CURSES)
270 +       has_curses=true
271 +       AC_DEFINE(NO_COLOR_CURSES)
272 +       AC_DEFINE(USE_SYSV_CURSES)
273 +       CURSES_INCLUDEDIR="-I/usr/5include"
274 +       CURSES_LIBS="/usr/5lib/libcurses.a /usr/5lib/libtermcap.a"
275 +       AC_MSG_RESULT(Please note that some screen refreshs may fail)
276 +])
277 +
278 +AC_DEFUN(AC_USE_OSF1_CURSES, [
279 +       AC_MSG_RESULT(Using OSF1 curses)
280 +       search_ncurses=false
281 +       screen_manager="OSF1 curses"
282 +       AC_DEFINE(HAS_CURSES)
283 +       has_curses=true
284 +       AC_DEFINE(NO_COLOR_CURSES)
285 +       AC_DEFINE(USE_SYSV_CURSES)
286 +       CURSES_LIBS="-lcurses"
287 +])
288 +
289 +AC_DEFUN(AC_USE_SYSV_CURSES, [
290 +       AC_MSG_RESULT(Using SysV curses)
291 +       AC_DEFINE(HAS_CURSES)
292 +       has_curses=true
293 +       AC_DEFINE(USE_SYSV_CURSES)
294 +       search_ncurses=false
295 +       screen_manager="SysV/curses"
296 +       CURSES_LIBS="-lcurses"
297 +])
298 +
299 +dnl AC_ARG_WITH(bsd-curses,
300 +dnl [--with-bsd-curses         Used to compile with bsd curses, not very fancy],
301 +dnl    search_ncurses=false
302 +dnl    screen_manager="Ultrix/cursesX"
303 +dnl    if test $system = ULTRIX
304 +dnl    then
305 +dnl        THIS_CURSES=cursesX
306 +dnl        else
307 +dnl        THIS_CURSES=curses
308 +dnl    fi
309 +dnl
310 +dnl    CURSES_LIBS="-l$THIS_CURSES -ltermcap"
311 +dnl    AC_DEFINE(HAS_CURSES)
312 +dnl    has_curses=true
313 +dnl    AC_DEFINE(USE_BSD_CURSES)
314 +dnl    AC_MSG_RESULT(Please note that some screen refreshs may fail)
315 +dnl    AC_MSG_WARN(Use of the bsdcurses extension has some)
316 +dnl    AC_MSG_WARN(display/input problems.)
317 +dnl    AC_MSG_WARN(Reconsider using xcurses)
318 +dnl)
319 +
320 +       
321 +dnl
322 +dnl Parameters: directory filename cureses_LIBS curses_INCLUDEDIR nicename
323 +dnl
324 +AC_DEFUN(AC_NCURSES, [
325 +    if $search_ncurses
326 +    then
327 +        if test -f $1/$2
328 +       then
329 +           AC_MSG_RESULT(Found ncurses on $1/$2)
330 +           CURSES_LIBS="$3"
331 +           CURSES_INCLUDEDIR="$4"
332 +           search_ncurses=false
333 +           screen_manager=$5
334 +            AC_DEFINE(HAS_CURSES)
335 +            has_curses=true
336 +           AC_DEFINE(USE_NCURSES)
337 +       fi
338 +    fi
339 +])
340 +
341 +AC_DEFUN(AC_SEARCH_NCURSES, [
342 +    AC_CHECKING("location of ncurses.h file")
343 +
344 +    AC_NCURSES(/usr/include, ncurses.h, -lncurses,, "ncurses on /usr/include")
345 +    AC_NCURSES(/usr/include/ncurses, ncurses.h, -lncurses, -I/usr/include/ncurses, "ncurses on /usr/include/ncurses")
346 +    AC_NCURSES(/usr/local/include, ncurses.h, -L/usr/local/lib -lncurses, -I/usr/local/include, "ncurses on /usr/local")
347 +    AC_NCURSES(/usr/local/include/ncurses, ncurses.h, -L/usr/local/lib -L/usr/local/lib/ncurses -lncurses, -I/usr/local/include/ncurses, "ncurses on /usr/local/include/ncurses")
348 +
349 +    AC_NCURSES(/usr/local/include/ncurses, curses.h, -L/usr/local/lib -lncurses, -I/usr/local/include/ncurses -DRENAMED_NCURSES, "renamed ncurses on /usr/local/.../ncurses")
350 +
351 +    AC_NCURSES(/usr/include/ncurses, curses.h, -lncurses, -I/usr/include/ncurses -DRENAMED_NCURSES, "renamed ncurses on /usr/include/ncurses")
352 +
353 +    dnl
354 +    dnl We couldn't find ncurses, try SysV curses
355 +    dnl
356 +    if $search_ncurses 
357 +    then
358 +        AC_EGREP_HEADER(init_color, /usr/include/curses.h,
359 +           AC_USE_SYSV_CURSES)
360 +       AC_EGREP_CPP(USE_NCURSES,[
361 +#include <curses.h>
362 +#ifdef __NCURSES_H
363 +#undef USE_NCURSES
364 +USE_NCURSES
365 +#endif
366 +],[
367 +       CURSES_INCLUDEDIR="$CURSES_INCLUDEDIR -DRENAMED_NCURSES"
368 +        AC_DEFINE(HAS_CURSES)
369 +       has_curses=true
370 +        AC_DEFINE(USE_NCURSES)
371 +        search_ncurses=false
372 +        screen_manager="ncurses installed as curses"
373 +])
374 +    fi
375 +
376 +    dnl
377 +    dnl Try SunOS 4.x /usr/5{lib,include} ncurses
378 +    dnl The flags USE_SUNOS_CURSES, USE_BSD_CURSES and BUGGY_CURSES
379 +    dnl should be replaced by a more fine grained selection routine
380 +    dnl
381 +    if $search_ncurses
382 +    then
383 +       if test -f /usr/5include/curses.h
384 +       then
385 +           AC_USE_SUNOS_CURSES
386 +        fi
387 +    else
388 +        # check for ncurses version, to properly ifdef mouse-fix
389 +       AC_MSG_CHECKING(for ncurses version)
390 +       ncurses_version=unknown
391 +cat > conftest.$ac_ext <<EOF
392 +[#]line __oline__ "configure"
393 +#include "confdefs.h"
394 +#ifdef RENAMED_NCURSES
395 +#include <curses.h>
396 +#else
397 +#include <ncurses.h>
398 +#endif
399 +#undef VERSION
400 +VERSION:NCURSES_VERSION
401 +EOF
402 +        if (eval "$ac_cpp conftest.$ac_ext") 2>&AC_FD_CC |
403 +  egrep "VERSION:" >conftest.out 2>&1; then
404 +changequote(,)dnl
405 +            ncurses_version=`cat conftest.out|sed -e 's/^[^"]*"//' -e 's/".*//'`
406 +changequote([,])dnl
407 +       fi
408 +       rm -rf conftest*
409 +        AC_MSG_RESULT($ncurses_version)
410 +       case "$ncurses_version" in
411 +changequote(,)dnl
412 +       4.[01])
413 +changequote([,])dnl
414 +            AC_DEFINE(NCURSES_970530,2)
415 +            ;;
416 +       1.9.9g)
417 +            AC_DEFINE(NCURSES_970530,1)
418 +            ;;
419 +       1*)
420 +            AC_DEFINE(NCURSES_970530,0)
421 +            ;;
422 +       esac
423 +    fi
424 +])
425 +
426 +
427 +
428 +
429 +
430 diff -Nru dalc-0.1/aclocal.m4 dalc-0.1.new/aclocal.m4
431 --- dalc-0.1/aclocal.m4 Thu Jan  1 01:00:00 1970
432 +++ dalc-0.1.new/aclocal.m4     Fri Nov 24 16:35:53 2000
433 @@ -0,0 +1,879 @@
434 +dnl aclocal.m4 generated automatically by aclocal 1.4a
435 +
436 +dnl Copyright (C) 1994, 1995-8, 1999 Free Software Foundation, Inc.
437 +dnl This file is free software; the Free Software Foundation
438 +dnl gives unlimited permission to copy and/or distribute it,
439 +dnl with or without modifications, as long as this notice is preserved.
440 +
441 +dnl This program is distributed in the hope that it will be useful,
442 +dnl but WITHOUT ANY WARRANTY, to the extent permitted by law; without
443 +dnl even the implied warranty of MERCHANTABILITY or FITNESS FOR A
444 +dnl PARTICULAR PURPOSE.
445 +
446 +dnl Curses detection: Munged from Midnight Commander's configure.in
447 +dnl
448 +dnl What it does:
449 +dnl =============
450 +dnl
451 +dnl - Determine which version of curses is installed on your system
452 +dnl   and set the -I/-L/-l compiler entries and add a few preprocessor
453 +dnl   symbols 
454 +dnl - Do an AC_SUBST on the CURSES_INCLUDEDIR and CURSES_LIBS so that
455 +dnl   @CURSES_INCLUDEDIR@ and @CURSES_LIBS@ will be available in
456 +dnl   Makefile.in's
457 +dnl - Modify the following configure variables (these are the only
458 +dnl   curses.m4 variables you can access from within configure.in)
459 +dnl   CURSES_INCLUDEDIR - contains -I's and possibly -DRENAMED_CURSES if
460 +dnl                       an ncurses.h that's been renamed to curses.h
461 +dnl                       is found.
462 +dnl   CURSES_LIBS       - sets -L and -l's appropriately
463 +dnl   CFLAGS            - if --with-sco, add -D_SVID3 
464 +dnl   has_curses        - exports result of tests to rest of configure
465 +dnl
466 +dnl Usage:
467 +dnl ======
468 +dnl 1) Add lines indicated below to acconfig.h
469 +dnl 2) call AC_CHECK_CURSES after AC_PROG_CC in your configure.in
470 +dnl 3) Instead of #include <curses.h> you should use the following to
471 +dnl    properly locate ncurses or curses header file
472 +dnl
473 +dnl    #if defined(USE_NCURSES) && !defined(RENAMED_NCURSES)
474 +dnl    #include <ncurses.h>
475 +dnl    #else
476 +dnl    #include <curses.h>
477 +dnl    #endif
478 +dnl
479 +dnl 4) Make sure to add @CURSES_INCLUDEDIR@ to your preprocessor flags
480 +dnl 5) Make sure to add @CURSES_LIBS@ to your linker flags or LIBS
481 +dnl
482 +dnl Notes with automake:
483 +dnl - call AM_CONDITIONAL(HAS_CURSES, test "$has_curses" = true) from
484 +dnl   configure.in
485 +dnl - your Makefile.am can look something like this
486 +dnl   -----------------------------------------------
487 +dnl   INCLUDES= blah blah blah $(CURSES_INCLUDEDIR) 
488 +dnl   if HAS_CURSES
489 +dnl   CURSES_TARGETS=name_of_curses_prog
490 +dnl   endif
491 +dnl   bin_PROGRAMS = other_programs $(CURSES_TARGETS)
492 +dnl   other_programs_SOURCES = blah blah blah
493 +dnl   name_of_curses_prog_SOURCES = blah blah blah
494 +dnl   other_programs_LDADD = blah
495 +dnl   name_of_curses_prog_LDADD = blah $(CURSES_LIBS)
496 +dnl   -----------------------------------------------
497 +dnl
498 +dnl
499 +dnl The following lines should be added to acconfig.h:
500 +dnl ==================================================
501 +dnl
502 +dnl /*=== Curses version detection defines ===*/
503 +dnl /* Found some version of curses that we're going to use */
504 +dnl #undef HAS_CURSES
505 +dnl    
506 +dnl /* Use SunOS SysV curses? */
507 +dnl #undef USE_SUNOS_CURSES
508 +dnl 
509 +dnl /* Use old BSD curses - not used right now */
510 +dnl #undef USE_BSD_CURSES
511 +dnl 
512 +dnl /* Use SystemV curses? */
513 +dnl #undef USE_SYSV_CURSES
514 +dnl 
515 +dnl /* Use Ncurses? */
516 +dnl #undef USE_NCURSES
517 +dnl 
518 +dnl /* If you Curses does not have color define this one */
519 +dnl #undef NO_COLOR_CURSES
520 +dnl 
521 +dnl /* Define if you want to turn on SCO-specific code */
522 +dnl #undef SCO_FLAVOR
523 +dnl 
524 +dnl /* Set to reflect version of ncurses *
525 +dnl  *   0 = version 1.*
526 +dnl  *   1 = version 1.9.9g
527 +dnl  *   2 = version 4.0/4.1 */
528 +dnl #undef NCURSES_970530
529 +dnl
530 +dnl /*=== End new stuff for acconfig.h ===*/
531 +dnl 
532 +
533 +
534 +AC_DEFUN(AC_CHECK_CURSES,[
535 +       search_ncurses=true
536 +       screen_manager=""
537 +       has_curses=false
538 +
539 +       CFLAGS=${CFLAGS--O}
540 +
541 +       AC_SUBST(CURSES_LIBS)
542 +       AC_SUBST(CURSES_INCLUDEDIR)
543 +
544 +       AC_ARG_WITH(sco,
545 +         [  --with-sco              Use this to turn on SCO-specific code],[
546 +         if test x$withval = xyes; then
547 +               AC_DEFINE(SCO_FLAVOR)
548 +               CFLAGS="$CFLAGS -D_SVID3"
549 +         fi
550 +       ])
551 +
552 +       AC_ARG_WITH(sunos-curses,
553 +         [  --with-sunos-curses     Used to force SunOS 4.x curses],[
554 +         if test x$withval = xyes; then
555 +               AC_USE_SUNOS_CURSES
556 +         fi
557 +       ])
558 +
559 +       AC_ARG_WITH(osf1-curses,
560 +         [  --with-osf1-curses      Used to force OSF/1 curses],[
561 +         if test x$withval = xyes; then
562 +               AC_USE_OSF1_CURSES
563 +         fi
564 +       ])
565 +
566 +       AC_ARG_WITH(vcurses,
567 +         [  --with-vcurses[=incdir] Used to force SysV curses],
568 +         if test x$withval != xyes; then
569 +               CURSES_INCLUDEDIR="-I$withval"
570 +         fi
571 +         AC_USE_SYSV_CURSES
572 +       )
573 +
574 +       AC_ARG_WITH(ncurses,
575 +         [  --with-ncurses[=dir]  Compile with ncurses/locate base dir],
576 +         if test x$withval = xno ; then
577 +               search_ncurses=false
578 +         elif test x$withval != xyes ; then
579 +               CURSES_LIBS="$LIBS -L$withval/lib -lncurses"
580 +               CURSES_INCLUDEDIR="-I$withval/include"
581 +               search_ncurses=false
582 +               screen_manager="ncurses"
583 +               AC_DEFINE(USE_NCURSES)
584 +               AC_DEFINE(HAS_CURSES)
585 +               has_curses=true
586 +         fi
587 +       )
588 +
589 +       if $search_ncurses
590 +       then
591 +               AC_SEARCH_NCURSES()
592 +       fi
593 +
594 +
595 +])
596 +
597 +
598 +AC_DEFUN(AC_USE_SUNOS_CURSES, [
599 +       search_ncurses=false
600 +       screen_manager="SunOS 4.x /usr/5include curses"
601 +       AC_MSG_RESULT(Using SunOS 4.x /usr/5include curses)
602 +       AC_DEFINE(USE_SUNOS_CURSES)
603 +       AC_DEFINE(HAS_CURSES)
604 +       has_curses=true
605 +       AC_DEFINE(NO_COLOR_CURSES)
606 +       AC_DEFINE(USE_SYSV_CURSES)
607 +       CURSES_INCLUDEDIR="-I/usr/5include"
608 +       CURSES_LIBS="/usr/5lib/libcurses.a /usr/5lib/libtermcap.a"
609 +       AC_MSG_RESULT(Please note that some screen refreshs may fail)
610 +])
611 +
612 +AC_DEFUN(AC_USE_OSF1_CURSES, [
613 +       AC_MSG_RESULT(Using OSF1 curses)
614 +       search_ncurses=false
615 +       screen_manager="OSF1 curses"
616 +       AC_DEFINE(HAS_CURSES)
617 +       has_curses=true
618 +       AC_DEFINE(NO_COLOR_CURSES)
619 +       AC_DEFINE(USE_SYSV_CURSES)
620 +       CURSES_LIBS="-lcurses"
621 +])
622 +
623 +AC_DEFUN(AC_USE_SYSV_CURSES, [
624 +       AC_MSG_RESULT(Using SysV curses)
625 +       AC_DEFINE(HAS_CURSES)
626 +       has_curses=true
627 +       AC_DEFINE(USE_SYSV_CURSES)
628 +       search_ncurses=false
629 +       screen_manager="SysV/curses"
630 +       CURSES_LIBS="-lcurses"
631 +])
632 +
633 +dnl AC_ARG_WITH(bsd-curses,
634 +dnl [--with-bsd-curses         Used to compile with bsd curses, not very fancy],
635 +dnl    search_ncurses=false
636 +dnl    screen_manager="Ultrix/cursesX"
637 +dnl    if test $system = ULTRIX
638 +dnl    then
639 +dnl        THIS_CURSES=cursesX
640 +dnl        else
641 +dnl        THIS_CURSES=curses
642 +dnl    fi
643 +dnl
644 +dnl    CURSES_LIBS="-l$THIS_CURSES -ltermcap"
645 +dnl    AC_DEFINE(HAS_CURSES)
646 +dnl    has_curses=true
647 +dnl    AC_DEFINE(USE_BSD_CURSES)
648 +dnl    AC_MSG_RESULT(Please note that some screen refreshs may fail)
649 +dnl    AC_MSG_WARN(Use of the bsdcurses extension has some)
650 +dnl    AC_MSG_WARN(display/input problems.)
651 +dnl    AC_MSG_WARN(Reconsider using xcurses)
652 +dnl)
653 +
654 +       
655 +dnl
656 +dnl Parameters: directory filename cureses_LIBS curses_INCLUDEDIR nicename
657 +dnl
658 +AC_DEFUN(AC_NCURSES, [
659 +    if $search_ncurses
660 +    then
661 +        if test -f $1/$2
662 +       then
663 +           AC_MSG_RESULT(Found ncurses on $1/$2)
664 +           CURSES_LIBS="$3"
665 +           CURSES_INCLUDEDIR="$4"
666 +           search_ncurses=false
667 +           screen_manager=$5
668 +            AC_DEFINE(HAS_CURSES)
669 +            has_curses=true
670 +           AC_DEFINE(USE_NCURSES)
671 +       fi
672 +    fi
673 +])
674 +
675 +AC_DEFUN(AC_SEARCH_NCURSES, [
676 +    AC_CHECKING("location of ncurses.h file")
677 +
678 +    AC_NCURSES(/usr/include, ncurses.h, -lncurses,, "ncurses on /usr/include")
679 +    AC_NCURSES(/usr/include/ncurses, ncurses.h, -lncurses, -I/usr/include/ncurses, "ncurses on /usr/include/ncurses")
680 +    AC_NCURSES(/usr/local/include, ncurses.h, -L/usr/local/lib -lncurses, -I/usr/local/include, "ncurses on /usr/local")
681 +    AC_NCURSES(/usr/local/include/ncurses, ncurses.h, -L/usr/local/lib -L/usr/local/lib/ncurses -lncurses, -I/usr/local/include/ncurses, "ncurses on /usr/local/include/ncurses")
682 +
683 +    AC_NCURSES(/usr/local/include/ncurses, curses.h, -L/usr/local/lib -lncurses, -I/usr/local/include/ncurses -DRENAMED_NCURSES, "renamed ncurses on /usr/local/.../ncurses")
684 +
685 +    AC_NCURSES(/usr/include/ncurses, curses.h, -lncurses, -I/usr/include/ncurses -DRENAMED_NCURSES, "renamed ncurses on /usr/include/ncurses")
686 +
687 +    dnl
688 +    dnl We couldn't find ncurses, try SysV curses
689 +    dnl
690 +    if $search_ncurses 
691 +    then
692 +        AC_EGREP_HEADER(init_color, /usr/include/curses.h,
693 +           AC_USE_SYSV_CURSES)
694 +       AC_EGREP_CPP(USE_NCURSES,[
695 +#include <curses.h>
696 +#ifdef __NCURSES_H
697 +#undef USE_NCURSES
698 +USE_NCURSES
699 +#endif
700 +],[
701 +       CURSES_INCLUDEDIR="$CURSES_INCLUDEDIR -DRENAMED_NCURSES"
702 +        AC_DEFINE(HAS_CURSES)
703 +       has_curses=true
704 +        AC_DEFINE(USE_NCURSES)
705 +        search_ncurses=false
706 +        screen_manager="ncurses installed as curses"
707 +])
708 +    fi
709 +
710 +    dnl
711 +    dnl Try SunOS 4.x /usr/5{lib,include} ncurses
712 +    dnl The flags USE_SUNOS_CURSES, USE_BSD_CURSES and BUGGY_CURSES
713 +    dnl should be replaced by a more fine grained selection routine
714 +    dnl
715 +    if $search_ncurses
716 +    then
717 +       if test -f /usr/5include/curses.h
718 +       then
719 +           AC_USE_SUNOS_CURSES
720 +        fi
721 +    else
722 +        # check for ncurses version, to properly ifdef mouse-fix
723 +       AC_MSG_CHECKING(for ncurses version)
724 +       ncurses_version=unknown
725 +cat > conftest.$ac_ext <<EOF
726 +[#]line __oline__ "configure"
727 +#include "confdefs.h"
728 +#ifdef RENAMED_NCURSES
729 +#include <curses.h>
730 +#else
731 +#include <ncurses.h>
732 +#endif
733 +#undef VERSION
734 +VERSION:NCURSES_VERSION
735 +EOF
736 +        if (eval "$ac_cpp conftest.$ac_ext") 2>&AC_FD_CC |
737 +  egrep "VERSION:" >conftest.out 2>&1; then
738 +changequote(,)dnl
739 +            ncurses_version=`cat conftest.out|sed -e 's/^[^"]*"//' -e 's/".*//'`
740 +changequote([,])dnl
741 +       fi
742 +       rm -rf conftest*
743 +        AC_MSG_RESULT($ncurses_version)
744 +       case "$ncurses_version" in
745 +changequote(,)dnl
746 +       4.[01])
747 +changequote([,])dnl
748 +            AC_DEFINE(NCURSES_970530,2)
749 +            ;;
750 +       1.9.9g)
751 +            AC_DEFINE(NCURSES_970530,1)
752 +            ;;
753 +       1*)
754 +            AC_DEFINE(NCURSES_970530,0)
755 +            ;;
756 +       esac
757 +    fi
758 +])
759 +
760 +
761 +
762 +
763 +
764 +
765 +# Define a conditional.
766 +
767 +AC_DEFUN(AM_CONDITIONAL,
768 +[AC_SUBST($1_TRUE)
769 +AC_SUBST($1_FALSE)
770 +if $2; then
771 +  $1_TRUE=
772 +  $1_FALSE='#'
773 +else
774 +  $1_TRUE='#'
775 +  $1_FALSE=
776 +fi])
777 +
778 +# Do all the work for Automake.  This macro actually does too much --
779 +# some checks are only needed if your package does certain things.
780 +# But this isn't really a big deal.
781 +
782 +# serial 1
783 +
784 +dnl Usage:
785 +dnl AM_INIT_AUTOMAKE(package,version, [no-define])
786 +
787 +AC_DEFUN(AM_INIT_AUTOMAKE,
788 +[AC_REQUIRE([AC_PROG_INSTALL])
789 +dnl We require 2.13 because we rely on SHELL being computed by configure.
790 +AC_PREREQ([2.13])
791 +PACKAGE=[$1]
792 +AC_SUBST(PACKAGE)
793 +VERSION=[$2]
794 +AC_SUBST(VERSION)
795 +dnl test to see if srcdir already configured
796 +if test "`cd $srcdir && pwd`" != "`pwd`" && test -f $srcdir/config.status; then
797 +  AC_MSG_ERROR([source directory already configured; run "make distclean" there first])
798 +fi
799 +ifelse([$3],,
800 +AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE", [Name of package])
801 +AC_DEFINE_UNQUOTED(VERSION, "$VERSION", [Version number of package]))
802 +AC_REQUIRE([AM_SANITY_CHECK])
803 +AC_REQUIRE([AC_ARG_PROGRAM])
804 +dnl FIXME This is truly gross.
805 +missing_dir=`cd $ac_aux_dir && pwd`
806 +AM_MISSING_PROG(ACLOCAL, aclocal, $missing_dir)
807 +AM_MISSING_PROG(AUTOCONF, autoconf, $missing_dir)
808 +AM_MISSING_PROG(AUTOMAKE, automake, $missing_dir)
809 +AM_MISSING_PROG(AUTOHEADER, autoheader, $missing_dir)
810 +AM_MISSING_PROG(MAKEINFO, makeinfo, $missing_dir)
811 +AC_REQUIRE([AC_PROG_MAKE_SET])])
812 +
813 +#
814 +# Check to make sure that the build environment is sane.
815 +#
816 +
817 +AC_DEFUN(AM_SANITY_CHECK,
818 +[AC_MSG_CHECKING([whether build environment is sane])
819 +# Just in case
820 +sleep 1
821 +echo timestamp > conftestfile
822 +# Do `set' in a subshell so we don't clobber the current shell's
823 +# arguments.  Must try -L first in case configure is actually a
824 +# symlink; some systems play weird games with the mod time of symlinks
825 +# (eg FreeBSD returns the mod time of the symlink's containing
826 +# directory).
827 +if (
828 +   set X `ls -Lt $srcdir/configure conftestfile 2> /dev/null`
829 +   if test "[$]*" = "X"; then
830 +      # -L didn't work.
831 +      set X `ls -t $srcdir/configure conftestfile`
832 +   fi
833 +   if test "[$]*" != "X $srcdir/configure conftestfile" \
834 +      && test "[$]*" != "X conftestfile $srcdir/configure"; then
835 +
836 +      # If neither matched, then we have a broken ls.  This can happen
837 +      # if, for instance, CONFIG_SHELL is bash and it inherits a
838 +      # broken ls alias from the environment.  This has actually
839 +      # happened.  Such a system could not be considered "sane".
840 +      AC_MSG_ERROR([ls -t appears to fail.  Make sure there is not a broken
841 +alias in your environment])
842 +   fi
843 +
844 +   test "[$]2" = conftestfile
845 +   )
846 +then
847 +   # Ok.
848 +   :
849 +else
850 +   AC_MSG_ERROR([newly created file is older than distributed files!
851 +Check your system clock])
852 +fi
853 +rm -f conftest*
854 +AC_MSG_RESULT(yes)])
855 +
856 +dnl AM_MISSING_PROG(NAME, PROGRAM, DIRECTORY)
857 +dnl The program must properly implement --version.
858 +AC_DEFUN(AM_MISSING_PROG,
859 +[AC_MSG_CHECKING(for working $2)
860 +# Run test in a subshell; some versions of sh will print an error if
861 +# an executable is not found, even if stderr is redirected.
862 +# Redirect stdin to placate older versions of autoconf.  Sigh.
863 +if ($2 --version) < /dev/null > /dev/null 2>&1; then
864 +   $1=$2
865 +   AC_MSG_RESULT(found)
866 +else
867 +   $1="$3/missing $2"
868 +   AC_MSG_RESULT(missing)
869 +fi
870 +AC_SUBST($1)])
871 +
872 +# Like AC_CONFIG_HEADER, but automatically create stamp file.
873 +
874 +AC_DEFUN(AM_CONFIG_HEADER,
875 +[AC_PREREQ([2.12])
876 +AC_CONFIG_HEADER([$1])
877 +dnl When config.status generates a header, we must update the stamp-h file.
878 +dnl This file resides in the same directory as the config header
879 +dnl that is generated.  We must strip everything past the first ":",
880 +dnl and everything past the last "/".
881 +AC_OUTPUT_COMMANDS(changequote(<<,>>)dnl
882 +ifelse(patsubst(<<$1>>, <<[^ ]>>, <<>>), <<>>,
883 +<<test -z "<<$>>CONFIG_HEADERS" || echo timestamp > patsubst(<<$1>>, <<^\([^:]*/\)?.*>>, <<\1>>)stamp-h<<>>dnl>>,
884 +<<am_indx=1
885 +for am_file in <<$1>>; do
886 +  case " <<$>>CONFIG_HEADERS " in
887 +  *" <<$>>am_file "*<<)>>
888 +    echo timestamp > `echo <<$>>am_file | sed -e 's%:.*%%' -e 's%[^/]*$%%'`stamp-h$am_indx
889 +    ;;
890 +  esac
891 +  am_indx=`expr "<<$>>am_indx" + 1`
892 +done<<>>dnl>>)
893 +changequote([,]))])
894 +
895 +
896 +# serial 40 AC_PROG_LIBTOOL
897 +AC_DEFUN(AC_PROG_LIBTOOL,
898 +[AC_REQUIRE([AC_LIBTOOL_SETUP])dnl
899 +
900 +# Save cache, so that ltconfig can load it
901 +AC_CACHE_SAVE
902 +
903 +# Actually configure libtool.  ac_aux_dir is where install-sh is found.
904 +CC="$CC" CFLAGS="$CFLAGS" CPPFLAGS="$CPPFLAGS" \
905 +LD="$LD" LDFLAGS="$LDFLAGS" LIBS="$LIBS" \
906 +LN_S="$LN_S" NM="$NM" RANLIB="$RANLIB" \
907 +DLLTOOL="$DLLTOOL" AS="$AS" OBJDUMP="$OBJDUMP" \
908 +${CONFIG_SHELL-/bin/sh} $ac_aux_dir/ltconfig --no-reexec \
909 +$libtool_flags --no-verify $ac_aux_dir/ltmain.sh $lt_target \
910 +|| AC_MSG_ERROR([libtool configure failed])
911 +
912 +# Reload cache, that may have been modified by ltconfig
913 +AC_CACHE_LOAD
914 +
915 +# This can be used to rebuild libtool when needed
916 +LIBTOOL_DEPS="$ac_aux_dir/ltconfig $ac_aux_dir/ltmain.sh"
917 +
918 +# Always use our own libtool.
919 +LIBTOOL='$(SHELL) $(top_builddir)/libtool'
920 +AC_SUBST(LIBTOOL)dnl
921 +
922 +# Redirect the config.log output again, so that the ltconfig log is not
923 +# clobbered by the next message.
924 +exec 5>>./config.log
925 +])
926 +
927 +AC_DEFUN(AC_LIBTOOL_SETUP,
928 +[AC_PREREQ(2.13)dnl
929 +AC_REQUIRE([AC_ENABLE_SHARED])dnl
930 +AC_REQUIRE([AC_ENABLE_STATIC])dnl
931 +AC_REQUIRE([AC_ENABLE_FAST_INSTALL])dnl
932 +AC_REQUIRE([AC_CANONICAL_HOST])dnl
933 +AC_REQUIRE([AC_CANONICAL_BUILD])dnl
934 +AC_REQUIRE([AC_PROG_RANLIB])dnl
935 +AC_REQUIRE([AC_PROG_CC])dnl
936 +AC_REQUIRE([AC_PROG_LD])dnl
937 +AC_REQUIRE([AC_PROG_NM])dnl
938 +AC_REQUIRE([AC_PROG_LN_S])dnl
939 +dnl
940 +
941 +case "$target" in
942 +NONE) lt_target="$host" ;;
943 +*) lt_target="$target" ;;
944 +esac
945 +
946 +# Check for any special flags to pass to ltconfig.
947 +#
948 +# the following will cause an existing older ltconfig to fail, so
949 +# we ignore this at the expense of the cache file... Checking this 
950 +# will just take longer ... bummer!
951 +#libtool_flags="--cache-file=$cache_file"
952 +#
953 +test "$enable_shared" = no && libtool_flags="$libtool_flags --disable-shared"
954 +test "$enable_static" = no && libtool_flags="$libtool_flags --disable-static"
955 +test "$enable_fast_install" = no && libtool_flags="$libtool_flags --disable-fast-install"
956 +test "$ac_cv_prog_gcc" = yes && libtool_flags="$libtool_flags --with-gcc"
957 +test "$ac_cv_prog_gnu_ld" = yes && libtool_flags="$libtool_flags --with-gnu-ld"
958 +ifdef([AC_PROVIDE_AC_LIBTOOL_DLOPEN],
959 +[libtool_flags="$libtool_flags --enable-dlopen"])
960 +ifdef([AC_PROVIDE_AC_LIBTOOL_WIN32_DLL],
961 +[libtool_flags="$libtool_flags --enable-win32-dll"])
962 +AC_ARG_ENABLE(libtool-lock,
963 +  [  --disable-libtool-lock  avoid locking (might break parallel builds)])
964 +test "x$enable_libtool_lock" = xno && libtool_flags="$libtool_flags --disable-lock"
965 +test x"$silent" = xyes && libtool_flags="$libtool_flags --silent"
966 +
967 +# Some flags need to be propagated to the compiler or linker for good
968 +# libtool support.
969 +case "$lt_target" in
970 +*-*-irix6*)
971 +  # Find out which ABI we are using.
972 +  echo '[#]line __oline__ "configure"' > conftest.$ac_ext
973 +  if AC_TRY_EVAL(ac_compile); then
974 +    case "`/usr/bin/file conftest.o`" in
975 +    *32-bit*)
976 +      LD="${LD-ld} -32"
977 +      ;;
978 +    *N32*)
979 +      LD="${LD-ld} -n32"
980 +      ;;
981 +    *64-bit*)
982 +      LD="${LD-ld} -64"
983 +      ;;
984 +    esac
985 +  fi
986 +  rm -rf conftest*
987 +  ;;
988 +
989 +*-*-sco3.2v5*)
990 +  # On SCO OpenServer 5, we need -belf to get full-featured binaries.
991 +  SAVE_CFLAGS="$CFLAGS"
992 +  CFLAGS="$CFLAGS -belf"
993 +  AC_CACHE_CHECK([whether the C compiler needs -belf], lt_cv_cc_needs_belf,
994 +    [AC_TRY_LINK([],[],[lt_cv_cc_needs_belf=yes],[lt_cv_cc_needs_belf=no])])
995 +  if test x"$lt_cv_cc_needs_belf" != x"yes"; then
996 +    # this is probably gcc 2.8.0, egcs 1.0 or newer; no need for -belf
997 +    CFLAGS="$SAVE_CFLAGS"
998 +  fi
999 +  ;;
1000 +
1001 +ifdef([AC_PROVIDE_AC_LIBTOOL_WIN32_DLL],
1002 +[*-*-cygwin* | *-*-mingw*)
1003 +  AC_CHECK_TOOL(DLLTOOL, dlltool, false)
1004 +  AC_CHECK_TOOL(AS, as, false)
1005 +  AC_CHECK_TOOL(OBJDUMP, objdump, false)
1006 +  ;;
1007 +])
1008 +esac
1009 +])
1010 +
1011 +# AC_LIBTOOL_DLOPEN - enable checks for dlopen support
1012 +AC_DEFUN(AC_LIBTOOL_DLOPEN, [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])])
1013 +
1014 +# AC_LIBTOOL_WIN32_DLL - declare package support for building win32 dll's
1015 +AC_DEFUN(AC_LIBTOOL_WIN32_DLL, [AC_BEFORE([$0], [AC_LIBTOOL_SETUP])])
1016 +
1017 +# AC_ENABLE_SHARED - implement the --enable-shared flag
1018 +# Usage: AC_ENABLE_SHARED[(DEFAULT)]
1019 +#   Where DEFAULT is either `yes' or `no'.  If omitted, it defaults to
1020 +#   `yes'.
1021 +AC_DEFUN(AC_ENABLE_SHARED, [dnl
1022 +define([AC_ENABLE_SHARED_DEFAULT], ifelse($1, no, no, yes))dnl
1023 +AC_ARG_ENABLE(shared,
1024 +changequote(<<, >>)dnl
1025 +<<  --enable-shared[=PKGS]  build shared libraries [default=>>AC_ENABLE_SHARED_DEFAULT],
1026 +changequote([, ])dnl
1027 +[p=${PACKAGE-default}
1028 +case "$enableval" in
1029 +yes) enable_shared=yes ;;
1030 +no) enable_shared=no ;;
1031 +*)
1032 +  enable_shared=no
1033 +  # Look at the argument we got.  We use all the common list separators.
1034 +  IFS="${IFS=  }"; ac_save_ifs="$IFS"; IFS="${IFS}:,"
1035 +  for pkg in $enableval; do
1036 +    if test "X$pkg" = "X$p"; then
1037 +      enable_shared=yes
1038 +    fi
1039 +  done
1040 +  IFS="$ac_save_ifs"
1041 +  ;;
1042 +esac],
1043 +enable_shared=AC_ENABLE_SHARED_DEFAULT)dnl
1044 +])
1045 +
1046 +# AC_DISABLE_SHARED - set the default shared flag to --disable-shared
1047 +AC_DEFUN(AC_DISABLE_SHARED, [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl
1048 +AC_ENABLE_SHARED(no)])
1049 +
1050 +# AC_ENABLE_STATIC - implement the --enable-static flag
1051 +# Usage: AC_ENABLE_STATIC[(DEFAULT)]
1052 +#   Where DEFAULT is either `yes' or `no'.  If omitted, it defaults to
1053 +#   `yes'.
1054 +AC_DEFUN(AC_ENABLE_STATIC, [dnl
1055 +define([AC_ENABLE_STATIC_DEFAULT], ifelse($1, no, no, yes))dnl
1056 +AC_ARG_ENABLE(static,
1057 +changequote(<<, >>)dnl
1058 +<<  --enable-static[=PKGS]  build static libraries [default=>>AC_ENABLE_STATIC_DEFAULT],
1059 +changequote([, ])dnl
1060 +[p=${PACKAGE-default}
1061 +case "$enableval" in
1062 +yes) enable_static=yes ;;
1063 +no) enable_static=no ;;
1064 +*)
1065 +  enable_static=no
1066 +  # Look at the argument we got.  We use all the common list separators.
1067 +  IFS="${IFS=  }"; ac_save_ifs="$IFS"; IFS="${IFS}:,"
1068 +  for pkg in $enableval; do
1069 +    if test "X$pkg" = "X$p"; then
1070 +      enable_static=yes
1071 +    fi
1072 +  done
1073 +  IFS="$ac_save_ifs"
1074 +  ;;
1075 +esac],
1076 +enable_static=AC_ENABLE_STATIC_DEFAULT)dnl
1077 +])
1078 +
1079 +# AC_DISABLE_STATIC - set the default static flag to --disable-static
1080 +AC_DEFUN(AC_DISABLE_STATIC, [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl
1081 +AC_ENABLE_STATIC(no)])
1082 +
1083 +
1084 +# AC_ENABLE_FAST_INSTALL - implement the --enable-fast-install flag
1085 +# Usage: AC_ENABLE_FAST_INSTALL[(DEFAULT)]
1086 +#   Where DEFAULT is either `yes' or `no'.  If omitted, it defaults to
1087 +#   `yes'.
1088 +AC_DEFUN(AC_ENABLE_FAST_INSTALL, [dnl
1089 +define([AC_ENABLE_FAST_INSTALL_DEFAULT], ifelse($1, no, no, yes))dnl
1090 +AC_ARG_ENABLE(fast-install,
1091 +changequote(<<, >>)dnl
1092 +<<  --enable-fast-install[=PKGS]  optimize for fast installation [default=>>AC_ENABLE_FAST_INSTALL_DEFAULT],
1093 +changequote([, ])dnl
1094 +[p=${PACKAGE-default}
1095 +case "$enableval" in
1096 +yes) enable_fast_install=yes ;;
1097 +no) enable_fast_install=no ;;
1098 +*)
1099 +  enable_fast_install=no
1100 +  # Look at the argument we got.  We use all the common list separators.
1101 +  IFS="${IFS=  }"; ac_save_ifs="$IFS"; IFS="${IFS}:,"
1102 +  for pkg in $enableval; do
1103 +    if test "X$pkg" = "X$p"; then
1104 +      enable_fast_install=yes
1105 +    fi
1106 +  done
1107 +  IFS="$ac_save_ifs"
1108 +  ;;
1109 +esac],
1110 +enable_fast_install=AC_ENABLE_FAST_INSTALL_DEFAULT)dnl
1111 +])
1112 +
1113 +# AC_ENABLE_FAST_INSTALL - set the default to --disable-fast-install
1114 +AC_DEFUN(AC_DISABLE_FAST_INSTALL, [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl
1115 +AC_ENABLE_FAST_INSTALL(no)])
1116 +
1117 +# AC_PROG_LD - find the path to the GNU or non-GNU linker
1118 +AC_DEFUN(AC_PROG_LD,
1119 +[AC_ARG_WITH(gnu-ld,
1120 +[  --with-gnu-ld           assume the C compiler uses GNU ld [default=no]],
1121 +test "$withval" = no || with_gnu_ld=yes, with_gnu_ld=no)
1122 +AC_REQUIRE([AC_PROG_CC])dnl
1123 +AC_REQUIRE([AC_CANONICAL_HOST])dnl
1124 +AC_REQUIRE([AC_CANONICAL_BUILD])dnl
1125 +ac_prog=ld
1126 +if test "$ac_cv_prog_gcc" = yes; then
1127 +  # Check if gcc -print-prog-name=ld gives a path.
1128 +  AC_MSG_CHECKING([for ld used by GCC])
1129 +  ac_prog=`($CC -print-prog-name=ld) 2>&5`
1130 +  case "$ac_prog" in
1131 +    # Accept absolute paths.
1132 +changequote(,)dnl
1133 +    [\\/]* | [A-Za-z]:[\\/]*)
1134 +      re_direlt='/[^/][^/]*/\.\./'
1135 +changequote([,])dnl
1136 +      # Canonicalize the path of ld
1137 +      ac_prog=`echo $ac_prog| sed 's%\\\\%/%g'`
1138 +      while echo $ac_prog | grep "$re_direlt" > /dev/null 2>&1; do
1139 +       ac_prog=`echo $ac_prog| sed "s%$re_direlt%/%"`
1140 +      done
1141 +      test -z "$LD" && LD="$ac_prog"
1142 +      ;;
1143 +  "")
1144 +    # If it fails, then pretend we aren't using GCC.
1145 +    ac_prog=ld
1146 +    ;;
1147 +  *)
1148 +    # If it is relative, then search for the first ld in PATH.
1149 +    with_gnu_ld=unknown
1150 +    ;;
1151 +  esac
1152 +elif test "$with_gnu_ld" = yes; then
1153 +  AC_MSG_CHECKING([for GNU ld])
1154 +else
1155 +  AC_MSG_CHECKING([for non-GNU ld])
1156 +fi
1157 +AC_CACHE_VAL(ac_cv_path_LD,
1158 +[if test -z "$LD"; then
1159 +  IFS="${IFS=  }"; ac_save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR-:}"
1160 +  for ac_dir in $PATH; do
1161 +    test -z "$ac_dir" && ac_dir=.
1162 +    if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then
1163 +      ac_cv_path_LD="$ac_dir/$ac_prog"
1164 +      # Check to see if the program is GNU ld.  I'd rather use --version,
1165 +      # but apparently some GNU ld's only accept -v.
1166 +      # Break only if it was the GNU/non-GNU ld that we prefer.
1167 +      if "$ac_cv_path_LD" -v 2>&1 < /dev/null | egrep '(GNU|with BFD)' > /dev/null; then
1168 +       test "$with_gnu_ld" != no && break
1169 +      else
1170 +       test "$with_gnu_ld" != yes && break
1171 +      fi
1172 +    fi
1173 +  done
1174 +  IFS="$ac_save_ifs"
1175 +else
1176 +  ac_cv_path_LD="$LD" # Let the user override the test with a path.
1177 +fi])
1178 +LD="$ac_cv_path_LD"
1179 +if test -n "$LD"; then
1180 +  AC_MSG_RESULT($LD)
1181 +else
1182 +  AC_MSG_RESULT(no)
1183 +fi
1184 +test -z "$LD" && AC_MSG_ERROR([no acceptable ld found in \$PATH])
1185 +AC_PROG_LD_GNU
1186 +])
1187 +
1188 +AC_DEFUN(AC_PROG_LD_GNU,
1189 +[AC_CACHE_CHECK([if the linker ($LD) is GNU ld], ac_cv_prog_gnu_ld,
1190 +[# I'd rather use --version here, but apparently some GNU ld's only accept -v.
1191 +if $LD -v 2>&1 </dev/null | egrep '(GNU|with BFD)' 1>&5; then
1192 +  ac_cv_prog_gnu_ld=yes
1193 +else
1194 +  ac_cv_prog_gnu_ld=no
1195 +fi])
1196 +])
1197 +
1198 +# AC_PROG_NM - find the path to a BSD-compatible name lister
1199 +AC_DEFUN(AC_PROG_NM,
1200 +[AC_MSG_CHECKING([for BSD-compatible nm])
1201 +AC_CACHE_VAL(ac_cv_path_NM,
1202 +[if test -n "$NM"; then
1203 +  # Let the user override the test.
1204 +  ac_cv_path_NM="$NM"
1205 +else
1206 +  IFS="${IFS=  }"; ac_save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR-:}"
1207 +  for ac_dir in $PATH /usr/ccs/bin /usr/ucb /bin; do
1208 +    test -z "$ac_dir" && ac_dir=.
1209 +    if test -f $ac_dir/nm || test -f $ac_dir/nm$ac_exeext ; then
1210 +      # Check to see if the nm accepts a BSD-compat flag.
1211 +      # Adding the `sed 1q' prevents false positives on HP-UX, which says:
1212 +      #   nm: unknown option "B" ignored
1213 +      if ($ac_dir/nm -B /dev/null 2>&1 | sed '1q'; exit 0) | egrep /dev/null >/dev/null; then
1214 +       ac_cv_path_NM="$ac_dir/nm -B"
1215 +       break
1216 +      elif ($ac_dir/nm -p /dev/null 2>&1 | sed '1q'; exit 0) | egrep /dev/null >/dev/null; then
1217 +       ac_cv_path_NM="$ac_dir/nm -p"
1218 +       break
1219 +      else
1220 +       ac_cv_path_NM=${ac_cv_path_NM="$ac_dir/nm"} # keep the first match, but
1221 +       continue # so that we can try to find one that supports BSD flags
1222 +      fi
1223 +    fi
1224 +  done
1225 +  IFS="$ac_save_ifs"
1226 +  test -z "$ac_cv_path_NM" && ac_cv_path_NM=nm
1227 +fi])
1228 +NM="$ac_cv_path_NM"
1229 +AC_MSG_RESULT([$NM])
1230 +])
1231 +
1232 +# AC_CHECK_LIBM - check for math library
1233 +AC_DEFUN(AC_CHECK_LIBM,
1234 +[AC_REQUIRE([AC_CANONICAL_HOST])dnl
1235 +LIBM=
1236 +case "$lt_target" in
1237 +*-*-beos* | *-*-cygwin*)
1238 +  # These system don't have libm
1239 +  ;;
1240 +*-ncr-sysv4.3*)
1241 +  AC_CHECK_LIB(mw, _mwvalidcheckl, LIBM="-lmw")
1242 +  AC_CHECK_LIB(m, main, LIBM="$LIBM -lm")
1243 +  ;;
1244 +*)
1245 +  AC_CHECK_LIB(m, main, LIBM="-lm")
1246 +  ;;
1247 +esac
1248 +])
1249 +
1250 +# AC_LIBLTDL_CONVENIENCE[(dir)] - sets LIBLTDL to the link flags for
1251 +# the libltdl convenience library and INCLTDL to the include flags for
1252 +# the libltdl header and adds --enable-ltdl-convenience to the
1253 +# configure arguments.  Note that LIBLTDL and INCLTDL are not
1254 +# AC_SUBSTed, nor is AC_CONFIG_SUBDIRS called.  If DIR is not
1255 +# provided, it is assumed to be `libltdl'.  LIBLTDL will be prefixed
1256 +# with '${top_builddir}/' and INCLTDL will be prefixed with
1257 +# '${top_srcdir}/' (note the single quotes!).  If your package is not
1258 +# flat and you're not using automake, define top_builddir and
1259 +# top_srcdir appropriately in the Makefiles.
1260 +AC_DEFUN(AC_LIBLTDL_CONVENIENCE, [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl
1261 +  case "$enable_ltdl_convenience" in
1262 +  no) AC_MSG_ERROR([this package needs a convenience libltdl]) ;;
1263 +  "") enable_ltdl_convenience=yes
1264 +      ac_configure_args="$ac_configure_args --enable-ltdl-convenience" ;;
1265 +  esac
1266 +  LIBLTDL='${top_builddir}/'ifelse($#,1,[$1],['libltdl'])/libltdlc.la
1267 +  INCLTDL='-I${top_srcdir}/'ifelse($#,1,[$1],['libltdl'])
1268 +])
1269 +
1270 +# AC_LIBLTDL_INSTALLABLE[(dir)] - sets LIBLTDL to the link flags for
1271 +# the libltdl installable library and INCLTDL to the include flags for
1272 +# the libltdl header and adds --enable-ltdl-install to the configure
1273 +# arguments.  Note that LIBLTDL and INCLTDL are not AC_SUBSTed, nor is
1274 +# AC_CONFIG_SUBDIRS called.  If DIR is not provided and an installed
1275 +# libltdl is not found, it is assumed to be `libltdl'.  LIBLTDL will
1276 +# be prefixed with '${top_builddir}/' and INCLTDL will be prefixed
1277 +# with '${top_srcdir}/' (note the single quotes!).  If your package is
1278 +# not flat and you're not using automake, define top_builddir and
1279 +# top_srcdir appropriately in the Makefiles.
1280 +# In the future, this macro may have to be called after AC_PROG_LIBTOOL.
1281 +AC_DEFUN(AC_LIBLTDL_INSTALLABLE, [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl
1282 +  AC_CHECK_LIB(ltdl, main,
1283 +  [test x"$enable_ltdl_install" != xyes && enable_ltdl_install=no],
1284 +  [if test x"$enable_ltdl_install" = xno; then
1285 +     AC_MSG_WARN([libltdl not installed, but installation disabled])
1286 +   else
1287 +     enable_ltdl_install=yes
1288 +   fi
1289 +  ])
1290 +  if test x"$enable_ltdl_install" = x"yes"; then
1291 +    ac_configure_args="$ac_configure_args --enable-ltdl-install"
1292 +    LIBLTDL='${top_builddir}/'ifelse($#,1,[$1],['libltdl'])/libltdl.la
1293 +    INCLTDL='-I${top_srcdir}/'ifelse($#,1,[$1],['libltdl'])
1294 +  else
1295 +    ac_configure_args="$ac_configure_args --enable-ltdl-install=no"
1296 +    LIBLTDL="-lltdl"
1297 +    INCLTDL=
1298 +  fi
1299 +])
1300 +
1301 +dnl old names
1302 +AC_DEFUN(AM_PROG_LIBTOOL, [indir([AC_PROG_LIBTOOL])])dnl
1303 +AC_DEFUN(AM_ENABLE_SHARED, [indir([AC_ENABLE_SHARED], $@)])dnl
1304 +AC_DEFUN(AM_ENABLE_STATIC, [indir([AC_ENABLE_STATIC], $@)])dnl
1305 +AC_DEFUN(AM_DISABLE_SHARED, [indir([AC_DISABLE_SHARED], $@)])dnl
1306 +AC_DEFUN(AM_DISABLE_STATIC, [indir([AC_DISABLE_STATIC], $@)])dnl
1307 +AC_DEFUN(AM_PROG_LD, [indir([AC_PROG_LD])])dnl
1308 +AC_DEFUN(AM_PROG_NM, [indir([AC_PROG_NM])])dnl
1309 +
1310 +dnl This is just to silence aclocal about the macro not being used
1311 +ifelse([AC_DISABLE_FAST_INSTALL])dnl
1312 +
1313 diff -Nru dalc-0.1/configure.in dalc-0.1.new/configure.in
1314 --- dalc-0.1/configure.in       Thu Jan  1 01:00:00 1970
1315 +++ dalc-0.1.new/configure.in   Fri Nov 24 16:28:43 2000
1316 @@ -0,0 +1,32 @@
1317 +dnl Process this file with autoconf to produce a configure script.
1318 +AC_INIT(dalexpr.h)
1319 +
1320 +AM_INIT_AUTOMAKE(dalc, 0.1)
1321 +AM_CONFIG_HEADER(config.h)
1322 +
1323 +dnl Checks for programs.
1324 +AC_PROG_CXX
1325 +AC_PROG_INSTALL
1326 +AM_PROG_LIBTOOL
1327 +
1328 +dnl Checks for libraries.
1329 +dnl Replace `main' with a function in -lm:
1330 +AC_CHECK_LIB(m, main)
1331 +dnl Replace `main' with a function in -lmenu:
1332 +AC_CHECK_LIB(menu, main)
1333 +dnl Replace `main' with a function in -lncurses:
1334 +AC_CHECK_LIB(ncurses, main)
1335 +
1336 +dnl Checks for header files.
1337 +AC_HEADER_STDC
1338 +AC_CHECK_HEADERS(unistd.h)
1339 +
1340 +dnl Checks for typedefs, structures, and compiler characteristics.
1341 +AC_C_CONST
1342 +
1343 +dnl Checks for library functions.
1344 +AC_CHECK_FUNCS(strerror strstr)
1345 +
1346 +AC_CHECK_CURSES
1347 +
1348 +AC_OUTPUT(Makefile)
1349 diff -Nru dalc-0.1/dalc.C dalc-0.1.new/dalc.C
1350 --- dalc-0.1/dalc.C     Thu Dec  9 08:01:35 1999
1351 +++ dalc-0.1.new/dalc.C Thu Jan  1 01:00:00 1970
1352 @@ -1,495 +0,0 @@
1353 -/*
1354 - * Dalc
1355 - * A powerful scientific DAL calculator
1356 - * Copyright (C) 1999 Daniel Beer
1357 - *
1358 - * This program is free software; you can redistribute it and/or modify
1359 - * it under the terms of the GNU General Public License as published by
1360 - * the Free Software Foundation; either version 2 of the License, or
1361 - * (at your option) any later version.
1362 - *
1363 - * This program is distributed in the hope that it will be useful,
1364 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
1365 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
1366 - * GNU General Public License for more details.
1367 - *
1368 - * You should have received a copy of the GNU General Public License
1369 - * along with this program; if not, write to the Free Software
1370 - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
1371 - */
1372 -
1373 -#include <ncurses.h>
1374 -#include <menu.h>
1375 -#include <stdio.h>
1376 -#include <strings.h>
1377 -#include <ctype.h>
1378 -#include <unistd.h>
1379 -#include <stdlib.h>
1380 -#include <math.h>
1381 -#include <errno.h>
1382 -#include "dalexpr.h"
1383 -
1384 -#define MAXITEMS            12
1385 -#define MAXINPUT            70
1386 -#define HISTORY             10
1387 -#define LMARGIN             2
1388 -#define MAXMSG              8
1389 -#define MSGSIZE             80
1390 -#define MAXSTAT             100
1391 -#define GSIZE               321
1392 -#define GSPACE              32
1393 -
1394 -typedef void (*callback_t)(void);
1395 -
1396 -DALExpr foo;
1397 -
1398 -struct {
1399 -  char text[MAXINPUT];
1400 -  unsigned int x;
1401 -} history[HISTORY];
1402 -
1403 -struct {
1404 -  int a, b, c;
1405 -} csc;
1406 -
1407 -struct {
1408 -  MENU *foo;
1409 -  ITEM *bar[MAXITEMS];
1410 -  callback_t funcs[MAXITEMS];
1411 -  int s, max;
1412 -} menu;
1413 -
1414 -struct {
1415 -  double val;
1416 -  int freq;
1417 -} stats[MAXSTAT];
1418 -int numstat;
1419 -
1420 -double xpoints[MAXSTAT], ypoints[MAXSTAT];
1421 -int numpoints;
1422 -char messages[MAXMSG][MSGSIZE];
1423 -
1424 -void
1425 -addMessage(char *text) {
1426 -  int i;
1427 -
1428 -  for(i=MAXMSG-1;i;i--) strcpy(messages[i], messages[i-1]);
1429 -  strncpy(messages[0], text, MSGSIZE);
1430 -}
1431 -
1432 -void
1433 -drawScreen(void) {
1434 -  int i;
1435 -
1436 -  bkgdset(csc.a);
1437 -  clear();
1438 -  for(i=0;i<MAXMSG;i++) mvaddstr(LINES-3-i, 0, messages[i]);
1439 -  bkgdset(csc.b);
1440 -  mvaddstr(LINES-2, 0, "  Dalc version 0.1");
1441 -  clrtoeol();
1442 -  mvaddstr(LINES-2, COLS/2, "Copyright (C) 1999 Daniel Beer");
1443 -}
1444 -
1445 -void
1446 -quitProg(void) {
1447 -  FILE *io;
1448 -  int i;
1449 -  char inp[200];
1450 -
1451 -  endwin();
1452 -  sprintf(inp, "%s/.dalcrc", getenv("HOME"));
1453 -  if((io=fopen(inp, "w"))!=NULL) {
1454 -    fprintf(io, "%e %e\n", foo.dtr, foo.ans);
1455 -    for(i=0;i<26;i++) fprintf(io, "%e\n", foo.vars[i]);
1456 -    fclose(io);
1457 -  }
1458 -  exit(0);
1459 -}
1460 -
1461 -void
1462 -loadStats(void) {
1463 -  char inp[50];
1464 -  char *temp;
1465 -  FILE *io;
1466 -
1467 -  bkgdset(csc.c);
1468 -  mvaddstr(LINES-1, 0, "Stats file: ");
1469 -  bkgdset(csc.a);
1470 -  clrtoeol();
1471 -  echo();
1472 -  getnstr(inp, sizeof(inp));
1473 -  noecho();
1474 -  if((io=fopen(inp, "r"))==NULL) {
1475 -    addMessage(strerror(errno));
1476 -    return;
1477 -  }
1478 -  foo.vars[13]=0;
1479 -  numstat=0;
1480 -  fscanf(io, "%s", inp);
1481 -  while(!feof(io)) {
1482 -    temp=strstr(inp, ";");
1483 -    if(temp==NULL) {
1484 -      stats[numstat].val=atof(inp);
1485 -      stats[numstat].freq=1;
1486 -      foo.vars[13]+=1.0;
1487 -    } else {
1488 -      temp++[0]=0;
1489 -      stats[numstat].val=atof(inp);
1490 -      stats[numstat].freq=atoi(temp);
1491 -      foo.vars[13]+=stats[numstat].freq;
1492 -    }
1493 -    if(numstat<MAXSTAT-1) numstat++;
1494 -    fscanf(io, "%s", inp);
1495 -  }
1496 -  fclose(io);
1497 -}
1498 -
1499 -void
1500 -loadPoints(void) {
1501 -  char inp[50];
1502 -  char *temp;
1503 -  FILE *io;
1504 -
1505 -  bkgdset(csc.c);
1506 -  mvaddstr(LINES-1, 0, "Points file: ");
1507 -  bkgdset(csc.a);
1508 -  clrtoeol();
1509 -  echo();
1510 -  getnstr(inp, sizeof(inp));
1511 -  noecho();
1512 -  if((io=fopen(inp, "r"))==NULL) {
1513 -    addMessage(strerror(errno));
1514 -    return;
1515 -  }
1516 -  fscanf(io, "%s", inp);
1517 -  numpoints=0;
1518 -  while(!feof(io)) {
1519 -    temp=strstr(inp, ",");
1520 -    if(temp!=NULL) {
1521 -      temp++[0]=0;
1522 -      if(temp[0]=='_') temp[0]='-';
1523 -    }
1524 -    if(inp[0]=='_') inp[0]='-';
1525 -    xpoints[numpoints]=atof(inp);
1526 -    ypoints[numpoints]=atof(temp);
1527 -    if(numpoints<MAXSTAT-1) numpoints++;
1528 -    fscanf(io, "%s", inp);
1529 -  }
1530 -  fclose(io);
1531 -}
1532 -
1533 -void
1534 -angleRadians(void) {
1535 -  foo.dtr=1.0;
1536 -  addMessage("Working in radians.");
1537 -}
1538 -
1539 -void
1540 -angleDegrees(void) {
1541 -  foo.dtr=M_PI/180.0;
1542 -  addMessage("Working in degrees.");
1543 -}
1544 -
1545 -void
1546 -angleCustom(void) {
1547 -  char inp[50];
1548 -
1549 -  bkgdset(csc.c);
1550 -  mvaddstr(LINES-1, 0, "Number of units in a circle: ");
1551 -  bkgdset(csc.a);
1552 -  clrtoeol();
1553 -  echo();
1554 -  getnstr(inp, sizeof(inp));
1555 -  noecho();
1556 -  foo.dtr=(M_PI*2)/atof(inp);
1557 -}
1558 -
1559 -void
1560 -saveVar(void) {
1561 -  int k;
1562 -
1563 -  bkgdset(csc.c);
1564 -  mvaddstr(LINES-1, 0, "Variable (A-Z) or F2 to cancel: ");
1565 -  k=0;
1566 -  while(!isalpha(k)) {
1567 -    k=getch();
1568 -    if(k==KEY_F(2)) return;
1569 -  }
1570 -  if(islower(k)) k-=32;
1571 -  foo.vars[k-'A']=foo.ans;
1572 -}
1573 -
1574 -void
1575 -sumStat(void) {
1576 -  char inp[200];
1577 -  int i;
1578 -  float sum=0.0;
1579 -
1580 -  bkgdset(csc.c);
1581 -  mvaddstr(LINES-1, 0, "Expression: ");
1582 -  bkgdset(csc.a);
1583 -  clrtoeol();
1584 -  echo();
1585 -  getnstr(inp, sizeof(inp));
1586 -  noecho();
1587 -  for(i=0;i<numstat;i++) {
1588 -    foo.vars[23]=stats[i].val;
1589 -    foo.evaluate(inp);
1590 -    sum+=foo.ans*stats[i].freq;
1591 -  }
1592 -  foo.ans=sum;
1593 -  addMessage(inp);
1594 -  addMessage("");
1595 -  snprintf(messages[0], MSGSIZE, " (sum) = %e, %f", foo.ans, foo.ans);
1596 -}
1597 -
1598 -void
1599 -quadratic(void) {
1600 -  double x;
1601 -
1602 -  x=foo.regressQuadratic(xpoints, ypoints, numpoints);
1603 -  addMessage("");
1604 -  snprintf(messages[0], MSGSIZE, "Match = %f", x);
1605 -  addMessage("");
1606 -  snprintf(messages[0], MSGSIZE, "f(X) = %fX^2 + %fX + %f",
1607 -          foo.coeff.a, foo.coeff.b, foo.coeff.c);
1608 -  addMessage("");
1609 -  snprintf(messages[0], MSGSIZE, "fd(X) = %fX + %f",
1610 -          foo.coeff.a*2, foo.coeff.b);
1611 -  addMessage("");
1612 -  snprintf(messages[0], MSGSIZE, "fi(X) = %fX^3 + %fX^2 + %fX",
1613 -          foo.coeff.a/3, foo.coeff.b/2, foo.coeff.c);
1614 -}
1615 -
1616 -void
1617 -linear(void) {
1618 -  double x;
1619 -  x=foo.regressLinear(xpoints, ypoints, numpoints);
1620 -  addMessage("");
1621 -  snprintf(messages[0], MSGSIZE, "Match = %f", x);
1622 -  addMessage("");
1623 -  snprintf(messages[0], MSGSIZE, "f(X) = %fX + %f",
1624 -          foo.coeff.a, foo.coeff.b);
1625 -  addMessage("");
1626 -  snprintf(messages[0], MSGSIZE, "fd(X) = %f",
1627 -          foo.coeff.a);
1628 -  addMessage("");
1629 -  snprintf(messages[0], MSGSIZE, "fi(X) = %fX^2 + %fX",
1630 -          foo.coeff.a/2, foo.coeff.b);
1631 -}
1632 -
1633 -void
1634 -graphFunc(void) {
1635 -  char inp[200], inp2[200];
1636 -  int values[GSIZE+1], valuesS[GSIZE+1];
1637 -  int x, y;
1638 -  FILE *io;
1639 -
1640 -  bkgdset(csc.c);
1641 -  mvaddstr(LINES-1, 0, "Function: ");
1642 -  bkgdset(csc.a);
1643 -  clrtoeol();
1644 -  echo();
1645 -  getnstr(inp, sizeof(inp));
1646 -  noecho();
1647 -  bkgdset(csc.c);
1648 -  mvaddstr(LINES-1, 0, "Second function (enter if none): ");
1649 -  bkgdset(csc.a);
1650 -  clrtoeol();
1651 -  echo();
1652 -  getnstr(inp2, sizeof(inp2));
1653 -  noecho();
1654 -  for(x=0;x<=GSIZE;x++) {
1655 -    foo.vars[23]=((double)x-GSIZE/2)/GSPACE;
1656 -    foo.evaluate(inp);
1657 -    values[x]=(int)((0.0-foo.ans)*GSPACE+GSIZE/2);
1658 -  }
1659 -  if(inp2[0]) {
1660 -    for(x=0;x<=GSIZE;x++) {
1661 -      foo.vars[23]=((double)x-GSIZE/2)/GSPACE;
1662 -      foo.evaluate(inp2);
1663 -      valuesS[x]=(int)((0.0-foo.ans)*GSPACE+GSIZE/2);
1664 -    }
1665 -  }
1666 -  sprintf(inp, "/tmp/dalc%d.ppm", getpid());
1667 -  if((io=fopen(inp, "w"))==NULL) {
1668 -    addMessage(strerror(errno));
1669 -    return;
1670 -  }
1671 -  fprintf(io, "P6\n%d %d\n255\n", GSIZE, GSIZE);
1672 -  for(y=0;y<GSIZE;y++) for(x=0;x<GSIZE;x++) {
1673 -    if(y>=values[x]&&y<=values[x+1]) fprintf(io, "%c%c%c", 0, 0, 0);
1674 -    else if(y<=values[x]&&y>=values[x+1]) fprintf(io, "%c%c%c", 0, 0, 0);
1675 -    else if(y>=valuesS[x]&&y<=valuesS[x+1]&&inp2[0])
1676 -      fprintf(io, "%c%c%c", 192, 0, 0);
1677 -    else if(y<=valuesS[x]&&y>=valuesS[x+1]&&inp2[0])
1678 -      fprintf(io, "%c%c%c", 192, 0, 0);
1679 -    else if(abs(x-GSIZE/2)<=1||abs(y-GSIZE/2)<=1||!(x%GSPACE&&y%GSPACE))
1680 -      fprintf(io, "%c%c%c", 0, 0, 192);
1681 -    else fprintf(io, "%c%c%c", 255, 255, 255);
1682 -  }
1683 -  fclose(io);
1684 -  if(getenv("DISPLAY")!=NULL) {
1685 -    switch(fork()) {
1686 -    case -1:
1687 -      addMessage(strerror(errno));
1688 -      break;
1689 -    case 0:
1690 -      execlp(VIEWER, VIEWER, inp, NULL);
1691 -      exit(-1);
1692 -    }
1693 -  }
1694 -  bkgdset(csc.c);
1695 -  mvaddstr(LINES-1, 0, "Save file as (*.gif, press enter to not save): ");
1696 -  bkgdset(csc.a);
1697 -  clrtoeol();
1698 -  echo();
1699 -  getnstr(inp2, sizeof(inp2));
1700 -  noecho();
1701 -  if(inp2[0]) {
1702 -    sprintf(inp, "%s /tmp/dalc%d.ppm > %s", CONVERTER, getpid(), inp2);
1703 -    if(system(inp)<0) addMessage(strerror(errno));
1704 -  }
1705 -  snprintf(inp, sizeof(inp), "/tmp/dalc%d.ppm", getpid());
1706 -  unlink(inp);
1707 -}
1708 -
1709 -void
1710 -init(void) {
1711 -  int i;
1712 -  FILE *io;
1713 -  char inp[200];
1714 -
1715 -  sprintf(inp, "%s/.dalcrc", getenv("HOME"));
1716 -  if((io=fopen(inp, "r"))!=NULL) {
1717 -    fscanf(io, "%le%le", &foo.dtr, &foo.ans);
1718 -    for(i=0;i<26;i++) fscanf(io, "%le", &foo.vars[i]);
1719 -    fclose(io);
1720 -  }
1721 -
1722 -  for(i=0;i<MAXMSG;i++) messages[i][0]=0;
1723 -  addMessage("Press F2 to toggle a menu.");
1724 -
1725 -  menu.s=0;
1726 -  menu.bar[0]=new_item(" Store ", " Store last result as a variable. ");
1727 -  menu.funcs[0]=saveVar;
1728 -  menu.bar[1]=new_item(" Load stats ", " Load statistical data from file. ");
1729 -  menu.funcs[1]=loadStats;
1730 -  menu.bar[2]=new_item(" Sumstat ", " Evaluate an expression for each stat. ");
1731 -  menu.funcs[2]=sumStat;
1732 -  menu.bar[3]=new_item(" Graph ", " Graph a function. ");
1733 -  menu.funcs[3]=graphFunc;
1734 -  menu.bar[4]=new_item(" Load points ", " Load graph points from a file. ");
1735 -  menu.funcs[4]=loadPoints;
1736 -  menu.bar[5]=new_item(" Quadratic ", " Attempt a quadratic regression. ");
1737 -  menu.funcs[5]=quadratic;
1738 -  menu.bar[6]=new_item(" Linear ", " Attempt a linear regression. ");
1739 -  menu.funcs[6]=linear;
1740 -  menu.bar[7]=new_item(" Radians ", " Measure angles in radians. ");
1741 -  menu.funcs[7]=angleRadians;
1742 -  menu.bar[8]=new_item(" Degrees ", " Measure angles in degrees. ");
1743 -  menu.funcs[8]=angleDegrees;
1744 -  menu.bar[9]=new_item(" Custom angles ", 
1745 -                      " Specify an angular measurement system. ");
1746 -  menu.funcs[9]=angleCustom;
1747 -  menu.bar[10]=new_item(" Exit ", " Exit the program. ");
1748 -  menu.funcs[10]=quitProg;
1749 -  menu.bar[11]=NULL;
1750 -  menu.max=11;
1751 -  menu.foo=new_menu(menu.bar);
1752 -  set_menu_mark(menu.foo, "* ");
1753 -
1754 -  csc.a=A_NORMAL;
1755 -  csc.b=A_REVERSE;
1756 -  csc.c=A_BOLD;
1757 -}
1758 -
1759 -void
1760 -showMenu(void) {
1761 -  int k=0;
1762 -
1763 -  post_menu(menu.foo);
1764 -  while(k!=KEY_F(2)) {
1765 -    k=getch();
1766 -    switch(k) {
1767 -    case KEY_UP:
1768 -      if(--menu.s<0) menu.s=menu.max-1;
1769 -      set_current_item(menu.foo, menu.bar[menu.s]);
1770 -      break;
1771 -    case KEY_DOWN:
1772 -      if(++menu.s>=menu.max) menu.s=0;
1773 -      set_current_item(menu.foo, menu.bar[menu.s]);
1774 -      break;
1775 -    case '\n':
1776 -      menu.funcs[menu.s]();
1777 -      k=KEY_F(2);
1778 -      break;
1779 -    }
1780 -  }
1781 -  unpost_menu(menu.foo);
1782 -  drawScreen();
1783 -}
1784 -
1785 -void
1786 -expressionMode(void) {
1787 -  unsigned int k=0, y=0, i, j;
1788 -
1789 -  history[y].text[0]=0;
1790 -  history[y].x=0;
1791 -  drawScreen();
1792 -  for(;;) {
1793 -    bkgdset(csc.c);
1794 -    mvaddstr(LINES-1, 0, "> ");
1795 -    bkgdset(csc.a);
1796 -    addstr(history[y].text);
1797 -    clrtoeol();
1798 -    move(LINES-1, history[y].x+LMARGIN);
1799 -    k=getch();
1800 -    if(k>=' '&&k<127&&(j=strlen(history[y].text))<MAXINPUT-1) {
1801 -      history[y].text[j+1]=0;
1802 -      for(i=j;i>history[y].x;i--) history[y].text[i]=history[y].text[i-1];
1803 -      history[y].text[history[y].x++]=k;
1804 -    } else if((k==8||k==127||k==KEY_BACKSPACE)&&
1805 -             history[y].text[0]&&history[y].x) {
1806 -      j=strlen(history[y].text);
1807 -      history[y].x--;
1808 -      for(i=history[y].x;i<j;) history[y].text[i]=history[y].text[++i];
1809 -    } else if(k==4&&history[y].x<strlen(history[y].text)) {
1810 -      j=strlen(history[y].text);
1811 -      for(i=history[y].x;i<j;) history[y].text[i]=history[y].text[++i];
1812 -    } else if(k==KEY_LEFT&&history[y].x) history[y].x--;
1813 -    else if(k==KEY_RIGHT&&history[y].x<strlen(history[y].text)) history[y].x++;
1814 -    else if(k==KEY_F(2)) showMenu();
1815 -    else if(k==1) history[y].x=0;
1816 -    else if(k==5) history[y].x=strlen(history[y].text);
1817 -    else if(k=='\n'&&history[y].text[0]) {
1818 -      foo.evaluate(history[y].text);
1819 -      addMessage(history[y].text);
1820 -      addMessage("");
1821 -      snprintf(messages[0], MSGSIZE, " = %e, %f", foo.ans, foo.ans);
1822 -      drawScreen();
1823 -      strcpy(history[0].text, history[y].text);
1824 -      history[0].x=history[y].x;
1825 -      for(i=HISTORY-1;i;i--) {
1826 -       history[i].x=history[i-1].x;
1827 -       strcpy(history[i].text, history[i-1].text);
1828 -      }
1829 -      history[0].text[0]=0;
1830 -      history[0].x=0;
1831 -      y=0;
1832 -    } else if(k==KEY_UP&&y<HISTORY-1) y++;
1833 -    else if(k==KEY_DOWN&&y) y--;
1834 -    else if(k==12) drawScreen();
1835 -  }
1836 -}
1837 -
1838 -int
1839 -main(void) {
1840 -  initscr();
1841 -  cbreak();
1842 -  noecho();
1843 -  keypad(stdscr, TRUE);
1844 -  init();
1845 -  expressionMode();
1846 -  endwin();
1847 -}
1848 diff -Nru dalc-0.1/dalc.cc dalc-0.1.new/dalc.cc
1849 --- dalc-0.1/dalc.cc    Thu Jan  1 01:00:00 1970
1850 +++ dalc-0.1.new/dalc.cc        Fri Nov 24 15:58:24 2000
1851 @@ -0,0 +1,495 @@
1852 +/*
1853 + * Dalc
1854 + * A powerful scientific DAL calculator
1855 + * Copyright (C) 1999 Daniel Beer
1856 + *
1857 + * This program is free software; you can redistribute it and/or modify
1858 + * it under the terms of the GNU General Public License as published by
1859 + * the Free Software Foundation; either version 2 of the License, or
1860 + * (at your option) any later version.
1861 + *
1862 + * This program is distributed in the hope that it will be useful,
1863 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
1864 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
1865 + * GNU General Public License for more details.
1866 + *
1867 + * You should have received a copy of the GNU General Public License
1868 + * along with this program; if not, write to the Free Software
1869 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
1870 + */
1871 +
1872 +#include <ncurses.h>
1873 +#include <menu.h>
1874 +#include <stdio.h>
1875 +#include <string.h>
1876 +#include <ctype.h>
1877 +#include <unistd.h>
1878 +#include <stdlib.h>
1879 +#include <math.h>
1880 +#include <errno.h>
1881 +#include "dalexpr.h"
1882 +
1883 +#define MAXITEMS            12
1884 +#define MAXINPUT            70
1885 +#define HISTORY             10
1886 +#define LMARGIN             2
1887 +#define MAXMSG              8
1888 +#define MSGSIZE             80
1889 +#define MAXSTAT             100
1890 +#define GSIZE               321
1891 +#define GSPACE              32
1892 +
1893 +typedef void (*callback_t)(void);
1894 +
1895 +DALExpr foo;
1896 +
1897 +struct {
1898 +  char text[MAXINPUT];
1899 +  unsigned int x;
1900 +} history[HISTORY];
1901 +
1902 +struct {
1903 +  int a, b, c;
1904 +} csc;
1905 +
1906 +struct {
1907 +  MENU *foo;
1908 +  ITEM *bar[MAXITEMS];
1909 +  callback_t funcs[MAXITEMS];
1910 +  int s, max;
1911 +} menu;
1912 +
1913 +struct {
1914 +  double val;
1915 +  int freq;
1916 +} stats[MAXSTAT];
1917 +int numstat;
1918 +
1919 +double xpoints[MAXSTAT], ypoints[MAXSTAT];
1920 +int numpoints;
1921 +char messages[MAXMSG][MSGSIZE];
1922 +
1923 +void
1924 +addMessage(char *text) {
1925 +  int i;
1926 +
1927 +  for(i=MAXMSG-1;i;i--) strcpy(messages[i], messages[i-1]);
1928 +  strncpy(messages[0], text, MSGSIZE);
1929 +}
1930 +
1931 +void
1932 +drawScreen(void) {
1933 +  int i;
1934 +
1935 +  bkgdset(csc.a);
1936 +  clear();
1937 +  for(i=0;i<MAXMSG;i++) mvaddstr(LINES-3-i, 0, messages[i]);
1938 +  bkgdset(csc.b);
1939 +  mvaddstr(LINES-2, 0, "  Dalc version 0.1");
1940 +  clrtoeol();
1941 +  mvaddstr(LINES-2, COLS/2, "Copyright (C) 1999 Daniel Beer");
1942 +}
1943 +
1944 +void
1945 +quitProg(void) {
1946 +  FILE *io;
1947 +  int i;
1948 +  char inp[200];
1949 +
1950 +  endwin();
1951 +  sprintf(inp, "%s/.dalcrc", getenv("HOME"));
1952 +  if((io=fopen(inp, "w"))!=NULL) {
1953 +    fprintf(io, "%e %e\n", foo.dtr, foo.ans);
1954 +    for(i=0;i<26;i++) fprintf(io, "%e\n", foo.vars[i]);
1955 +    fclose(io);
1956 +  }
1957 +  exit(0);
1958 +}
1959 +
1960 +void
1961 +loadStats(void) {
1962 +  char inp[50];
1963 +  char *temp;
1964 +  FILE *io;
1965 +
1966 +  bkgdset(csc.c);
1967 +  mvaddstr(LINES-1, 0, "Stats file: ");
1968 +  bkgdset(csc.a);
1969 +  clrtoeol();
1970 +  echo();
1971 +  getnstr(inp, sizeof(inp));
1972 +  noecho();
1973 +  if((io=fopen(inp, "r"))==NULL) {
1974 +    addMessage(strerror(errno));
1975 +    return;
1976 +  }
1977 +  foo.vars[13]=0;
1978 +  numstat=0;
1979 +  fscanf(io, "%s", inp);
1980 +  while(!feof(io)) {
1981 +    temp=strstr(inp, ";");
1982 +    if(temp==NULL) {
1983 +      stats[numstat].val=atof(inp);
1984 +      stats[numstat].freq=1;
1985 +      foo.vars[13]+=1.0;
1986 +    } else {
1987 +      temp++[0]=0;
1988 +      stats[numstat].val=atof(inp);
1989 +      stats[numstat].freq=atoi(temp);
1990 +      foo.vars[13]+=stats[numstat].freq;
1991 +    }
1992 +    if(numstat<MAXSTAT-1) numstat++;
1993 +    fscanf(io, "%s", inp);
1994 +  }
1995 +  fclose(io);
1996 +}
1997 +
1998 +void
1999 +loadPoints(void) {
2000 +  char inp[50];
2001 +  char *temp;
2002 +  FILE *io;
2003 +
2004 +  bkgdset(csc.c);
2005 +  mvaddstr(LINES-1, 0, "Points file: ");
2006 +  bkgdset(csc.a);
2007 +  clrtoeol();
2008 +  echo();
2009 +  getnstr(inp, sizeof(inp));
2010 +  noecho();
2011 +  if((io=fopen(inp, "r"))==NULL) {
2012 +    addMessage(strerror(errno));
2013 +    return;
2014 +  }
2015 +  fscanf(io, "%s", inp);
2016 +  numpoints=0;
2017 +  while(!feof(io)) {
2018 +    temp=strstr(inp, ",");
2019 +    if(temp!=NULL) {
2020 +      temp++[0]=0;
2021 +      if(temp[0]=='_') temp[0]='-';
2022 +    }
2023 +    if(inp[0]=='_') inp[0]='-';
2024 +    xpoints[numpoints]=atof(inp);
2025 +    ypoints[numpoints]=atof(temp);
2026 +    if(numpoints<MAXSTAT-1) numpoints++;
2027 +    fscanf(io, "%s", inp);
2028 +  }
2029 +  fclose(io);
2030 +}
2031 +
2032 +void
2033 +angleRadians(void) {
2034 +  foo.dtr=1.0;
2035 +  addMessage("Working in radians.");
2036 +}
2037 +
2038 +void
2039 +angleDegrees(void) {
2040 +  foo.dtr=M_PI/180.0;
2041 +  addMessage("Working in degrees.");
2042 +}
2043 +
2044 +void
2045 +angleCustom(void) {
2046 +  char inp[50];
2047 +
2048 +  bkgdset(csc.c);
2049 +  mvaddstr(LINES-1, 0, "Number of units in a circle: ");
2050 +  bkgdset(csc.a);
2051 +  clrtoeol();
2052 +  echo();
2053 +  getnstr(inp, sizeof(inp));
2054 +  noecho();
2055 +  foo.dtr=(M_PI*2)/atof(inp);
2056 +}
2057 +
2058 +void
2059 +saveVar(void) {
2060 +  int k;
2061 +
2062 +  bkgdset(csc.c);
2063 +  mvaddstr(LINES-1, 0, "Variable (A-Z) or F2 to cancel: ");
2064 +  k=0;
2065 +  while(!isalpha(k)) {
2066 +    k=getch();
2067 +    if(k==KEY_F(2)) return;
2068 +  }
2069 +  if(islower(k)) k-=32;
2070 +  foo.vars[k-'A']=foo.ans;
2071 +}
2072 +
2073 +void
2074 +sumStat(void) {
2075 +  char inp[200];
2076 +  int i;
2077 +  float sum=0.0;
2078 +
2079 +  bkgdset(csc.c);
2080 +  mvaddstr(LINES-1, 0, "Expression: ");
2081 +  bkgdset(csc.a);
2082 +  clrtoeol();
2083 +  echo();
2084 +  getnstr(inp, sizeof(inp));
2085 +  noecho();
2086 +  for(i=0;i<numstat;i++) {
2087 +    foo.vars[23]=stats[i].val;
2088 +    foo.evaluate(inp);
2089 +    sum+=foo.ans*stats[i].freq;
2090 +  }
2091 +  foo.ans=sum;
2092 +  addMessage(inp);
2093 +  addMessage("");
2094 +  snprintf(messages[0], MSGSIZE, " (sum) = %e, %f", foo.ans, foo.ans);
2095 +}
2096 +
2097 +void
2098 +quadratic(void) {
2099 +  double x;
2100 +
2101 +  x=foo.regressQuadratic(xpoints, ypoints, numpoints);
2102 +  addMessage("");
2103 +  snprintf(messages[0], MSGSIZE, "Match = %f", x);
2104 +  addMessage("");
2105 +  snprintf(messages[0], MSGSIZE, "f(X) = %fX^2 + %fX + %f",
2106 +          foo.coeff.a, foo.coeff.b, foo.coeff.c);
2107 +  addMessage("");
2108 +  snprintf(messages[0], MSGSIZE, "fd(X) = %fX + %f",
2109 +          foo.coeff.a*2, foo.coeff.b);
2110 +  addMessage("");
2111 +  snprintf(messages[0], MSGSIZE, "fi(X) = %fX^3 + %fX^2 + %fX",
2112 +          foo.coeff.a/3, foo.coeff.b/2, foo.coeff.c);
2113 +}
2114 +
2115 +void
2116 +linear(void) {
2117 +  double x;
2118 +  x=foo.regressLinear(xpoints, ypoints, numpoints);
2119 +  addMessage("");
2120 +  snprintf(messages[0], MSGSIZE, "Match = %f", x);
2121 +  addMessage("");
2122 +  snprintf(messages[0], MSGSIZE, "f(X) = %fX + %f",
2123 +          foo.coeff.a, foo.coeff.b);
2124 +  addMessage("");
2125 +  snprintf(messages[0], MSGSIZE, "fd(X) = %f",
2126 +          foo.coeff.a);
2127 +  addMessage("");
2128 +  snprintf(messages[0], MSGSIZE, "fi(X) = %fX^2 + %fX",
2129 +          foo.coeff.a/2, foo.coeff.b);
2130 +}
2131 +
2132 +void
2133 +graphFunc(void) {
2134 +  char inp[200], inp2[200];
2135 +  int values[GSIZE+1], valuesS[GSIZE+1];
2136 +  int x, y;
2137 +  FILE *io;
2138 +
2139 +  bkgdset(csc.c);
2140 +  mvaddstr(LINES-1, 0, "Function: ");
2141 +  bkgdset(csc.a);
2142 +  clrtoeol();
2143 +  echo();
2144 +  getnstr(inp, sizeof(inp));
2145 +  noecho();
2146 +  bkgdset(csc.c);
2147 +  mvaddstr(LINES-1, 0, "Second function (enter if none): ");
2148 +  bkgdset(csc.a);
2149 +  clrtoeol();
2150 +  echo();
2151 +  getnstr(inp2, sizeof(inp2));
2152 +  noecho();
2153 +  for(x=0;x<=GSIZE;x++) {
2154 +    foo.vars[23]=((double)x-GSIZE/2)/GSPACE;
2155 +    foo.evaluate(inp);
2156 +    values[x]=(int)((0.0-foo.ans)*GSPACE+GSIZE/2);
2157 +  }
2158 +  if(inp2[0]) {
2159 +    for(x=0;x<=GSIZE;x++) {
2160 +      foo.vars[23]=((double)x-GSIZE/2)/GSPACE;
2161 +      foo.evaluate(inp2);
2162 +      valuesS[x]=(int)((0.0-foo.ans)*GSPACE+GSIZE/2);
2163 +    }
2164 +  }
2165 +  sprintf(inp, "/tmp/dalc%d.ppm", getpid());
2166 +  if((io=fopen(inp, "w"))==NULL) {
2167 +    addMessage(strerror(errno));
2168 +    return;
2169 +  }
2170 +  fprintf(io, "P6\n%d %d\n255\n", GSIZE, GSIZE);
2171 +  for(y=0;y<GSIZE;y++) for(x=0;x<GSIZE;x++) {
2172 +    if(y>=values[x]&&y<=values[x+1]) fprintf(io, "%c%c%c", 0, 0, 0);
2173 +    else if(y<=values[x]&&y>=values[x+1]) fprintf(io, "%c%c%c", 0, 0, 0);
2174 +    else if(y>=valuesS[x]&&y<=valuesS[x+1]&&inp2[0])
2175 +      fprintf(io, "%c%c%c", 192, 0, 0);
2176 +    else if(y<=valuesS[x]&&y>=valuesS[x+1]&&inp2[0])
2177 +      fprintf(io, "%c%c%c", 192, 0, 0);
2178 +    else if(abs(x-GSIZE/2)<=1||abs(y-GSIZE/2)<=1||!(x%GSPACE&&y%GSPACE))
2179 +      fprintf(io, "%c%c%c", 0, 0, 192);
2180 +    else fprintf(io, "%c%c%c", 255, 255, 255);
2181 +  }
2182 +  fclose(io);
2183 +  if(getenv("DISPLAY")!=NULL) {
2184 +    switch(fork()) {
2185 +    case -1:
2186 +      addMessage(strerror(errno));
2187 +      break;
2188 +    case 0:
2189 +      execlp(VIEWER, VIEWER, inp, NULL);
2190 +      exit(-1);
2191 +    }
2192 +  }
2193 +  bkgdset(csc.c);
2194 +  mvaddstr(LINES-1, 0, "Save file as (*.gif, press enter to not save): ");
2195 +  bkgdset(csc.a);
2196 +  clrtoeol();
2197 +  echo();
2198 +  getnstr(inp2, sizeof(inp2));
2199 +  noecho();
2200 +  if(inp2[0]) {
2201 +    sprintf(inp, "%s /tmp/dalc%d.ppm > %s", CONVERTER, getpid(), inp2);
2202 +    if(system(inp)<0) addMessage(strerror(errno));
2203 +  }
2204 +  snprintf(inp, sizeof(inp), "/tmp/dalc%d.ppm", getpid());
2205 +  unlink(inp);
2206 +}
2207 +
2208 +void
2209 +init(void) {
2210 +  int i;
2211 +  FILE *io;
2212 +  char inp[200];
2213 +
2214 +  sprintf(inp, "%s/.dalcrc", getenv("HOME"));
2215 +  if((io=fopen(inp, "r"))!=NULL) {
2216 +    fscanf(io, "%le%le", &foo.dtr, &foo.ans);
2217 +    for(i=0;i<26;i++) fscanf(io, "%le", &foo.vars[i]);
2218 +    fclose(io);
2219 +  }
2220 +
2221 +  for(i=0;i<MAXMSG;i++) messages[i][0]=0;
2222 +  addMessage("Press F2 to toggle a menu.");
2223 +
2224 +  menu.s=0;
2225 +  menu.bar[0]=new_item(" Store ", " Store last result as a variable. ");
2226 +  menu.funcs[0]=saveVar;
2227 +  menu.bar[1]=new_item(" Load stats ", " Load statistical data from file. ");
2228 +  menu.funcs[1]=loadStats;
2229 +  menu.bar[2]=new_item(" Sumstat ", " Evaluate an expression for each stat. ");
2230 +  menu.funcs[2]=sumStat;
2231 +  menu.bar[3]=new_item(" Graph ", " Graph a function. ");
2232 +  menu.funcs[3]=graphFunc;
2233 +  menu.bar[4]=new_item(" Load points ", " Load graph points from a file. ");
2234 +  menu.funcs[4]=loadPoints;
2235 +  menu.bar[5]=new_item(" Quadratic ", " Attempt a quadratic regression. ");
2236 +  menu.funcs[5]=quadratic;
2237 +  menu.bar[6]=new_item(" Linear ", " Attempt a linear regression. ");
2238 +  menu.funcs[6]=linear;
2239 +  menu.bar[7]=new_item(" Radians ", " Measure angles in radians. ");
2240 +  menu.funcs[7]=angleRadians;
2241 +  menu.bar[8]=new_item(" Degrees ", " Measure angles in degrees. ");
2242 +  menu.funcs[8]=angleDegrees;
2243 +  menu.bar[9]=new_item(" Custom angles ", 
2244 +                      " Specify an angular measurement system. ");
2245 +  menu.funcs[9]=angleCustom;
2246 +  menu.bar[10]=new_item(" Exit ", " Exit the program. ");
2247 +  menu.funcs[10]=quitProg;
2248 +  menu.bar[11]=NULL;
2249 +  menu.max=11;
2250 +  menu.foo=new_menu(menu.bar);
2251 +  set_menu_mark(menu.foo, "* ");
2252 +
2253 +  csc.a=A_NORMAL;
2254 +  csc.b=A_REVERSE;
2255 +  csc.c=A_BOLD;
2256 +}
2257 +
2258 +void
2259 +showMenu(void) {
2260 +  int k=0;
2261 +
2262 +  post_menu(menu.foo);
2263 +  while(k!=KEY_F(2)) {
2264 +    k=getch();
2265 +    switch(k) {
2266 +    case KEY_UP:
2267 +      if(--menu.s<0) menu.s=menu.max-1;
2268 +      set_current_item(menu.foo, menu.bar[menu.s]);
2269 +      break;
2270 +    case KEY_DOWN:
2271 +      if(++menu.s>=menu.max) menu.s=0;
2272 +      set_current_item(menu.foo, menu.bar[menu.s]);
2273 +      break;
2274 +    case '\n':
2275 +      menu.funcs[menu.s]();
2276 +      k=KEY_F(2);
2277 +      break;
2278 +    }
2279 +  }
2280 +  unpost_menu(menu.foo);
2281 +  drawScreen();
2282 +}
2283 +
2284 +void
2285 +expressionMode(void) {
2286 +  unsigned int k=0, y=0, i, j;
2287 +
2288 +  history[y].text[0]=0;
2289 +  history[y].x=0;
2290 +  drawScreen();
2291 +  for(;;) {
2292 +    bkgdset(csc.c);
2293 +    mvaddstr(LINES-1, 0, "> ");
2294 +    bkgdset(csc.a);
2295 +    addstr(history[y].text);
2296 +    clrtoeol();
2297 +    move(LINES-1, history[y].x+LMARGIN);
2298 +    k=getch();
2299 +    if(k>=' '&&k<127&&(j=strlen(history[y].text))<MAXINPUT-1) {
2300 +      history[y].text[j+1]=0;
2301 +      for(i=j;i>history[y].x;i--) history[y].text[i]=history[y].text[i-1];
2302 +      history[y].text[history[y].x++]=k;
2303 +    } else if((k==8||k==127||k==KEY_BACKSPACE)&&
2304 +             history[y].text[0]&&history[y].x) {
2305 +      j=strlen(history[y].text);
2306 +      history[y].x--;
2307 +      for(i=history[y].x;i<j;) history[y].text[i]=history[y].text[++i];
2308 +    } else if(k==4&&history[y].x<strlen(history[y].text)) {
2309 +      j=strlen(history[y].text);
2310 +      for(i=history[y].x;i<j;) history[y].text[i]=history[y].text[++i];
2311 +    } else if(k==KEY_LEFT&&history[y].x) history[y].x--;
2312 +    else if(k==KEY_RIGHT&&history[y].x<strlen(history[y].text)) history[y].x++;
2313 +    else if(k==KEY_F(2)) showMenu();
2314 +    else if(k==1) history[y].x=0;
2315 +    else if(k==5) history[y].x=strlen(history[y].text);
2316 +    else if(k=='\n'&&history[y].text[0]) {
2317 +      foo.evaluate(history[y].text);
2318 +      addMessage(history[y].text);
2319 +      addMessage("");
2320 +      snprintf(messages[0], MSGSIZE, " = %e, %f", foo.ans, foo.ans);
2321 +      drawScreen();
2322 +      strcpy(history[0].text, history[y].text);
2323 +      history[0].x=history[y].x;
2324 +      for(i=HISTORY-1;i;i--) {
2325 +       history[i].x=history[i-1].x;
2326 +       strcpy(history[i].text, history[i-1].text);
2327 +      }
2328 +      history[0].text[0]=0;
2329 +      history[0].x=0;
2330 +      y=0;
2331 +    } else if(k==KEY_UP&&y<HISTORY-1) y++;
2332 +    else if(k==KEY_DOWN&&y) y--;
2333 +    else if(k==12) drawScreen();
2334 +  }
2335 +}
2336 +
2337 +int
2338 +main(void) {
2339 +  initscr();
2340 +  cbreak();
2341 +  noecho();
2342 +  keypad(stdscr, TRUE);
2343 +  init();
2344 +  expressionMode();
2345 +  endwin();
2346 +}
2347 diff -Nru dalc-0.1/dalexpr.C dalc-0.1.new/dalexpr.C
2348 --- dalc-0.1/dalexpr.C  Thu Dec  9 08:17:05 1999
2349 +++ dalc-0.1.new/dalexpr.C      Thu Jan  1 01:00:00 1970
2350 @@ -1,358 +0,0 @@
2351 -/*
2352 - * Dalc
2353 - * A powerful scientific DAL calculator
2354 - * Copyright (C) 1999 Daniel Beer
2355 - *
2356 - * This program is free software; you can redistribute it and/or modify
2357 - * it under the terms of the GNU General Public License as published by
2358 - * the Free Software Foundation; either version 2 of the License, or
2359 - * (at your option) any later version.
2360 - *
2361 - * This program is distributed in the hope that it will be useful,
2362 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
2363 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
2364 - * GNU General Public License for more details.
2365 - *
2366 - * You should have received a copy of the GNU General Public License
2367 - * along with this program; if not, write to the Free Software
2368 - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
2369 - */
2370 -
2371 -#include <stdio.h>
2372 -#include <stdlib.h>
2373 -#include <ctype.h>
2374 -#include <strings.h>
2375 -#include <math.h>
2376 -#include <time.h>
2377 -#include "dalexpr.h"
2378 -
2379 -DALExpr::DALExpr(void) {
2380 -  int i;
2381 -
2382 -  for(i=0;i<26;i++) vars[i]=0.0;
2383 -  dtr=1.0;
2384 -  ans=0.0;
2385 -}
2386 -
2387 -DALExpr::~DALExpr(void) {
2388 -}
2389 -
2390 -void
2391 -DALExpr::evaluate(const char *e) {
2392 -  int i, lt=-1;
2393 -
2394 -  srandom(time(NULL));
2395 -  for(i=0;i<MAXTOKENS;i++) tokens[i][0]=0;
2396 -
2397 -  num=0;
2398 -  tokens[0][0]=0;
2399 -  for(i=0;e[i];i++) {
2400 -    if(e[i]==',') {
2401 -      advanceToken();
2402 -      tokens[num][0]=')';
2403 -      tokens[num][1]=0;
2404 -      advanceToken();
2405 -      tokens[num][0]='(';
2406 -      tokens[num][1]=0;
2407 -      advanceToken();
2408 -    } else {
2409 -      if(lt!=tType(e[i])) advanceToken();
2410 -      if(tType(e[i])&&strlen(tokens[num])<TOKENSIZE-1) {
2411 -       tokens[num][strlen(tokens[num])+1]=0;
2412 -       tokens[num][strlen(tokens[num])]=e[i];
2413 -      }
2414 -      lt=tType(e[i]);
2415 -      if(!(lt%2)) lt=-1;
2416 -    }
2417 -  }
2418 -  if(tokens[num][0]) advanceToken();
2419 -
2420 -  breakDown(0);
2421 -  ans=tokenVal[0];
2422 -}
2423 -
2424 -double
2425 -DALExpr::functionF(double x) {
2426 -  switch(coeff.type) {
2427 -  case F_QUADRATIC: return x*x*coeff.a+x*coeff.b+coeff.c;
2428 -  case F_LINEAR: return x*coeff.a+coeff.b;
2429 -  }
2430 -  return 0.0;
2431 -}
2432 -
2433 -double
2434 -DALExpr::derivativeF(double x) {
2435 -  switch(coeff.type) {
2436 -  case F_QUADRATIC: return x*coeff.a*2.0+coeff.b;
2437 -  case F_LINEAR: return coeff.a;
2438 -  }
2439 -  return 0.0;
2440 -}
2441 -
2442 -double
2443 -DALExpr::integralF(double x) {
2444 -  switch(coeff.type) {
2445 -  case F_QUADRATIC: return (x*x*x*coeff.a)/3.0+(x*x*coeff.b)/2.0+x*coeff.c;
2446 -  case F_LINEAR: return (x*x*coeff.a)/2+x*coeff.b;
2447 -  }
2448 -  return 0.0;
2449 -}
2450 -
2451 -double
2452 -DALExpr::regressQuadratic(double *xpoints, double *ypoints, int numpoints) {
2453 -  double a, b, c, aa, bb, cc, diff, bdiff=10000000.0, step;
2454 -  int i;
2455 -
2456 -  coeff.type=F_QUADRATIC;
2457 -  coeff.a=0.0;
2458 -  coeff.b=0.0;
2459 -  coeff.c=0.0;
2460 -  for(step=1000.0;step>=0.0000001;step/=10) {
2461 -    aa=coeff.a;
2462 -    bb=coeff.b;
2463 -    cc=coeff.c;
2464 -    for(a=aa-step*10;a<=aa+step*10;a+=step)
2465 -      for(b=bb-step*10;b<=bb+step*10;b+=step)
2466 -       for(c=cc-step*10;c<=cc+step*10;c+=step) {
2467 -         diff=0.0;
2468 -         for(i=0;i<numpoints;i++)
2469 -           diff+=fabs(ypoints[i]-(a*xpoints[i]*xpoints[i]+b*xpoints[i]+c));
2470 -         if(diff<bdiff) {
2471 -           bdiff=diff;
2472 -           coeff.a=a;
2473 -           coeff.b=b;
2474 -           coeff.c=c;
2475 -         }
2476 -       }
2477 -  }
2478 -  return bdiff;
2479 -}
2480 -
2481 -double
2482 -DALExpr::regressLinear(double *xpoints, double *ypoints, int numpoints) {
2483 -  double a, b, aa, bb, diff, bdiff=10000000.0, step;
2484 -  int i;
2485 -
2486 -  coeff.type=F_LINEAR;
2487 -  coeff.a=0.0;
2488 -  coeff.b=0.0;
2489 -  for(step=1000.0;step>=0.0000001;step/=10) {
2490 -    aa=coeff.a;
2491 -    bb=coeff.b;
2492 -    for(a=aa-step*10;a<=aa+step*10;a+=step)
2493 -      for(b=bb-step*10;b<=bb+step*10;b+=step) {
2494 -       diff=0.0;
2495 -       for(i=0;i<numpoints;i++) diff+=fabs(ypoints[i]-(a*xpoints[i]+b));
2496 -       if(diff<bdiff) {
2497 -         bdiff=diff;
2498 -         coeff.a=a;
2499 -         coeff.b=b;
2500 -       }
2501 -      }
2502 -  }
2503 -  return bdiff;
2504 -}
2505 -
2506 -void
2507 -DALExpr::breakDown(int from) {
2508 -  int i;
2509 -  double j;
2510 -
2511 -  for(i=from;i<num;i++)
2512 -    if(!strcmp(tokens[i], "(")) {
2513 -      breakDown(i+1);
2514 -      remove(i);
2515 -      remove(i+1);
2516 -    }
2517 -  for(i=from;i<num&&strcmp(tokens[i], ")");i++) {
2518 -    if(!strcmp(tokens[i], "pi")) {
2519 -      tokenVal[i]=M_PI;
2520 -      tokens[i][0]='#';
2521 -    } else if(!strcmp(tokens[i], "e")) {
2522 -      tokenVal[i]=M_E;
2523 -      tokens[i][0]='#';
2524 -    } else if(!strcmp(tokens[i], "ans")) {
2525 -      tokenVal[i]=ans;
2526 -      tokens[i][0]='#';
2527 -    } else if(!strcmp(tokens[i], "rand")) {
2528 -      tokenVal[i]=random()%10000;
2529 -      tokenVal[i]/=10000.0;
2530 -      tokens[i][0]='#';
2531 -    } else if(isupper(tokens[i][0])) {
2532 -      tokenVal[i]=vars[tokens[i][0]-'A'];
2533 -      tokens[i][0]='#';
2534 -    }
2535 -  }
2536 -  for(i=from;i<num&&strcmp(tokens[i], ")");i++) {
2537 -    if(!(strcmp(tokens[i], "^")&&strcmp(tokens[i], "**"))) {
2538 -      tokenVal[i-1]=pow(tokenVal[i-1], tokenVal[i+1]);
2539 -      remove(i);
2540 -      remove(i);
2541 -      i--;
2542 -    } else if(!strcmp(tokens[i], "root")) {
2543 -      tokenVal[i-1]=pow(tokenVal[i+1], 1.0/tokenVal[i-1]);
2544 -      remove(i);
2545 -      remove(i);
2546 -      i--;
2547 -    }
2548 -  }
2549 -  for(i=from;i<num&&strcmp(tokens[i], ")");i++) {
2550 -    if(!strcmp(tokens[i], "sin")) {
2551 -      tokenVal[i+1]=sin(tokenVal[i+1]*dtr);
2552 -      remove(i);
2553 -    } else if(!strcmp(tokens[i], "cos")) {
2554 -      tokenVal[i+1]=cos(tokenVal[i+1]*dtr);
2555 -      remove(i);
2556 -    } else if(!strcmp(tokens[i], "tan")) {
2557 -      tokenVal[i+1]=tan(tokenVal[i+1]*dtr);
2558 -      remove(i);
2559 -    } else if(!strcmp(tokens[i], "sec")) {
2560 -      tokenVal[i+1]=1.0/cos(tokenVal[i+1]*dtr);
2561 -      remove(i);
2562 -    } else if(!strcmp(tokens[i], "asin")) {
2563 -      tokenVal[i+1]=asin(tokenVal[i+1])/dtr;
2564 -      remove(i);
2565 -    } else if(!strcmp(tokens[i], "acos")) {
2566 -      tokenVal[i+1]=acos(tokenVal[i+1])/dtr;
2567 -      remove(i);
2568 -    } else if(!strcmp(tokens[i], "atan")) {
2569 -      tokenVal[i+1]=atan(tokenVal[i+1])/dtr;
2570 -      remove(i);
2571 -    } else if(!strcmp(tokens[i], "atanr")) {
2572 -      tokenVal[i+1]=atan2(tokenVal[i+1], tokenVal[i+2])/dtr;
2573 -      remove(i);
2574 -      remove(i+1);
2575 -    } else if(!strcmp(tokens[i], "asec")) {
2576 -      tokenVal[i+1]=acos(1.0/tokenVal[i+1])/dtr;
2577 -      remove(i);
2578 -    } else if(!strcmp(tokens[i], "sinh")) {
2579 -      tokenVal[i+1]=sinh(tokenVal[i+1])/dtr;
2580 -      remove(i);
2581 -    } else if(!strcmp(tokens[i], "cosh")) {
2582 -      tokenVal[i+1]=cosh(tokenVal[i+1])/dtr;
2583 -      remove(i);
2584 -    } else if(!strcmp(tokens[i], "tanh")) {
2585 -      tokenVal[i+1]=tanh(tokenVal[i+1])/dtr;
2586 -      remove(i);
2587 -    } else if(!strcmp(tokens[i], "hypot")) {
2588 -      tokenVal[i+1]=hypot(tokenVal[i+1], tokenVal[i+2]);
2589 -      remove(i);
2590 -      remove(i+1);
2591 -    } else if(!strcmp(tokens[i], "abs")) {
2592 -      tokenVal[i+1]=fabs(tokenVal[i+1]);
2593 -      remove(i);
2594 -    } else if(!strcmp(tokens[i], "sqrt")) {
2595 -      tokenVal[i+1]=sqrt(tokenVal[i+1]);
2596 -      remove(i);
2597 -    } else if(!strcmp(tokens[i], "log")) {
2598 -      tokenVal[i+1]=log10(tokenVal[i+1]);
2599 -      remove(i);
2600 -    } else if(!strcmp(tokens[i], "f")) {
2601 -      tokenVal[i+1]=functionF(tokenVal[i+1]);
2602 -      remove(i);
2603 -    } else if(!strcmp(tokens[i], "fi")) {
2604 -      tokenVal[i+1]=integralF(tokenVal[i+1]);
2605 -      remove(i);
2606 -    } else if(!strcmp(tokens[i], "fd")) {
2607 -      tokenVal[i+1]=derivativeF(tokenVal[i+1]);
2608 -      remove(i);
2609 -    } else if(!strcmp(tokens[i], "ln")) {
2610 -      tokenVal[i+1]=log(tokenVal[i+1]);
2611 -      remove(i);
2612 -    } else if(!strcmp(tokens[i], "ceil")) {
2613 -      tokenVal[i+1]=ceil(tokenVal[i+1]);
2614 -      remove(i);
2615 -    } else if(!strcmp(tokens[i], "floor")) {
2616 -      tokenVal[i+1]=floor(tokenVal[i+1]);
2617 -      remove(i);
2618 -    } else if(!strcmp(tokens[i], "round")) {
2619 -      tokenVal[i+1]=rint(tokenVal[i+1]);
2620 -      remove(i);
2621 -    } else if(!strcmp(tokens[i], "!")) {
2622 -      j=tokenVal[i-1];
2623 -      if(j<0) tokenVal[i-1]=asin(2.0);
2624 -      else {
2625 -       tokenVal[i-1]=1.0;
2626 -       for(;j>0;j-=1.0) tokenVal[i-1]*=j;
2627 -      }
2628 -      remove(i);
2629 -      i--;
2630 -    } else if(!strcmp(tokens[i], "int")) {
2631 -      if(tokenVal[i+1]>0.0) tokenVal[i+1]=floor(tokenVal[i+1]);
2632 -      else tokenVal[i+1]=ceil(tokenVal[i+1]);
2633 -      remove(i);
2634 -    } else if(!strcmp(tokens[i], "frac")) {
2635 -      if(tokenVal[i+1]>0.0) tokenVal[i+1]-=floor(tokenVal[i+1]);
2636 -      else tokenVal[i+1]-=ceil(tokenVal[i+1]);
2637 -      remove(i);
2638 -    }
2639 -  }
2640 -  for(i=from;i<num&&strcmp(tokens[i], ")");i++) {
2641 -    if(!strcmp(tokens[i], "*")) {
2642 -      tokenVal[i-1]*=tokenVal[i+1];
2643 -      remove(i);
2644 -      remove(i);
2645 -      i-=2;
2646 -    } else if(!strcmp(tokens[i], "/")) {
2647 -      tokenVal[i-1]/=tokenVal[i+1];
2648 -      remove(i);
2649 -      remove(i);
2650 -      i-=2;
2651 -    } else if(tokens[i][0]=='#'&&tokens[i+1][0]=='#'&&i+1<num) {
2652 -      tokenVal[i]*=tokenVal[i+1];
2653 -      remove(i+1);
2654 -      i--;
2655 -    }
2656 -  }
2657 -  for(i=from;i<num&&strcmp(tokens[i], ")");i++) {
2658 -    if(!strcmp(tokens[i], "+")) {
2659 -      tokenVal[i-1]+=tokenVal[i+1];
2660 -      remove(i);
2661 -      remove(i);
2662 -      i--;
2663 -    } else if(!strcmp(tokens[i], "-")) {
2664 -      tokenVal[i-1]-=tokenVal[i+1];
2665 -      remove(i);
2666 -      remove(i);
2667 -      i--;
2668 -    }
2669 -  }
2670 -}
2671 -
2672 -double
2673 -DALExpr::getValue(int which) {
2674 -  if(which<0||which>=num) return 0.0;
2675 -  return atof(tokens[which]);
2676 -}
2677 -
2678 -void
2679 -DALExpr::remove(int which) {
2680 -  int i;
2681 -
2682 -  for(i=which+1;i<num;i++) {
2683 -    strcpy(tokens[i-1], tokens[i]);
2684 -    tokenVal[i-1]=tokenVal[i];
2685 -  }
2686 -  num--;
2687 -}
2688 -
2689 -int
2690 -DALExpr::tType(char k) {
2691 -  if(k<=' ') return 0;
2692 -  if(islower(k)) return 3;
2693 -  if(isupper(k)) return 2;
2694 -  if(isdigit(k)||k=='_'||k=='.') return 5;
2695 -  if(k=='('||k==')') return 4;
2696 -  return 1;
2697 -}
2698 -
2699 -void
2700 -DALExpr::advanceToken(void) {
2701 -  if(!tokens[num][0]||num>=MAXTOKENS-1) return;
2702 -  if(tType(tokens[num][0])==5) {
2703 -    if(tokens[num][0]=='_') tokens[num][0]='-';
2704 -    tokenVal[num]=atof(tokens[num]);
2705 -    tokens[num][0]='#';
2706 -  }
2707 -  num++;
2708 -}
2709 diff -Nru dalc-0.1/dalexpr.cc dalc-0.1.new/dalexpr.cc
2710 --- dalc-0.1/dalexpr.cc Thu Jan  1 01:00:00 1970
2711 +++ dalc-0.1.new/dalexpr.cc     Fri Nov 24 15:58:24 2000
2712 @@ -0,0 +1,358 @@
2713 +/*
2714 + * Dalc
2715 + * A powerful scientific DAL calculator
2716 + * Copyright (C) 1999 Daniel Beer
2717 + *
2718 + * This program is free software; you can redistribute it and/or modify
2719 + * it under the terms of the GNU General Public License as published by
2720 + * the Free Software Foundation; either version 2 of the License, or
2721 + * (at your option) any later version.
2722 + *
2723 + * This program is distributed in the hope that it will be useful,
2724 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
2725 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
2726 + * GNU General Public License for more details.
2727 + *
2728 + * You should have received a copy of the GNU General Public License
2729 + * along with this program; if not, write to the Free Software
2730 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
2731 + */
2732 +
2733 +#include <stdio.h>
2734 +#include <stdlib.h>
2735 +#include <ctype.h>
2736 +#include <string.h>
2737 +#include <math.h>
2738 +#include <time.h>
2739 +#include "dalexpr.h"
2740 +
2741 +DALExpr::DALExpr(void) {
2742 +  int i;
2743 +
2744 +  for(i=0;i<26;i++) vars[i]=0.0;
2745 +  dtr=1.0;
2746 +  ans=0.0;
2747 +}
2748 +
2749 +DALExpr::~DALExpr(void) {
2750 +}
2751 +
2752 +void
2753 +DALExpr::evaluate(const char *e) {
2754 +  int i, lt=-1;
2755 +
2756 +  srandom(time(NULL));
2757 +  for(i=0;i<MAXTOKENS;i++) tokens[i][0]=0;
2758 +
2759 +  num=0;
2760 +  tokens[0][0]=0;
2761 +  for(i=0;e[i];i++) {
2762 +    if(e[i]==',') {
2763 +      advanceToken();
2764 +      tokens[num][0]=')';
2765 +      tokens[num][1]=0;
2766 +      advanceToken();
2767 +      tokens[num][0]='(';
2768 +      tokens[num][1]=0;
2769 +      advanceToken();
2770 +    } else {
2771 +      if(lt!=tType(e[i])) advanceToken();
2772 +      if(tType(e[i])&&strlen(tokens[num])<TOKENSIZE-1) {
2773 +       tokens[num][strlen(tokens[num])+1]=0;
2774 +       tokens[num][strlen(tokens[num])]=e[i];
2775 +      }
2776 +      lt=tType(e[i]);
2777 +      if(!(lt%2)) lt=-1;
2778 +    }
2779 +  }
2780 +  if(tokens[num][0]) advanceToken();
2781 +
2782 +  breakDown(0);
2783 +  ans=tokenVal[0];
2784 +}
2785 +
2786 +double
2787 +DALExpr::functionF(double x) {
2788 +  switch(coeff.type) {
2789 +  case F_QUADRATIC: return x*x*coeff.a+x*coeff.b+coeff.c;
2790 +  case F_LINEAR: return x*coeff.a+coeff.b;
2791 +  }
2792 +  return 0.0;
2793 +}
2794 +
2795 +double
2796 +DALExpr::derivativeF(double x) {
2797 +  switch(coeff.type) {
2798 +  case F_QUADRATIC: return x*coeff.a*2.0+coeff.b;
2799 +  case F_LINEAR: return coeff.a;
2800 +  }
2801 +  return 0.0;
2802 +}
2803 +
2804 +double
2805 +DALExpr::integralF(double x) {
2806 +  switch(coeff.type) {
2807 +  case F_QUADRATIC: return (x*x*x*coeff.a)/3.0+(x*x*coeff.b)/2.0+x*coeff.c;
2808 +  case F_LINEAR: return (x*x*coeff.a)/2+x*coeff.b;
2809 +  }
2810 +  return 0.0;
2811 +}
2812 +
2813 +double
2814 +DALExpr::regressQuadratic(double *xpoints, double *ypoints, int numpoints) {
2815 +  double a, b, c, aa, bb, cc, diff, bdiff=10000000.0, step;
2816 +  int i;
2817 +
2818 +  coeff.type=F_QUADRATIC;
2819 +  coeff.a=0.0;
2820 +  coeff.b=0.0;
2821 +  coeff.c=0.0;
2822 +  for(step=1000.0;step>=0.0000001;step/=10) {
2823 +    aa=coeff.a;
2824 +    bb=coeff.b;
2825 +    cc=coeff.c;
2826 +    for(a=aa-step*10;a<=aa+step*10;a+=step)
2827 +      for(b=bb-step*10;b<=bb+step*10;b+=step)
2828 +       for(c=cc-step*10;c<=cc+step*10;c+=step) {
2829 +         diff=0.0;
2830 +         for(i=0;i<numpoints;i++)
2831 +           diff+=fabs(ypoints[i]-(a*xpoints[i]*xpoints[i]+b*xpoints[i]+c));
2832 +         if(diff<bdiff) {
2833 +           bdiff=diff;
2834 +           coeff.a=a;
2835 +           coeff.b=b;
2836 +           coeff.c=c;
2837 +         }
2838 +       }
2839 +  }
2840 +  return bdiff;
2841 +}
2842 +
2843 +double
2844 +DALExpr::regressLinear(double *xpoints, double *ypoints, int numpoints) {
2845 +  double a, b, aa, bb, diff, bdiff=10000000.0, step;
2846 +  int i;
2847 +
2848 +  coeff.type=F_LINEAR;
2849 +  coeff.a=0.0;
2850 +  coeff.b=0.0;
2851 +  for(step=1000.0;step>=0.0000001;step/=10) {
2852 +    aa=coeff.a;
2853 +    bb=coeff.b;
2854 +    for(a=aa-step*10;a<=aa+step*10;a+=step)
2855 +      for(b=bb-step*10;b<=bb+step*10;b+=step) {
2856 +       diff=0.0;
2857 +       for(i=0;i<numpoints;i++) diff+=fabs(ypoints[i]-(a*xpoints[i]+b));
2858 +       if(diff<bdiff) {
2859 +         bdiff=diff;
2860 +         coeff.a=a;
2861 +         coeff.b=b;
2862 +       }
2863 +      }
2864 +  }
2865 +  return bdiff;
2866 +}
2867 +
2868 +void
2869 +DALExpr::breakDown(int from) {
2870 +  int i;
2871 +  double j;
2872 +
2873 +  for(i=from;i<num;i++)
2874 +    if(!strcmp(tokens[i], "(")) {
2875 +      breakDown(i+1);
2876 +      remove(i);
2877 +      remove(i+1);
2878 +    }
2879 +  for(i=from;i<num&&strcmp(tokens[i], ")");i++) {
2880 +    if(!strcmp(tokens[i], "pi")) {
2881 +      tokenVal[i]=M_PI;
2882 +      tokens[i][0]='#';
2883 +    } else if(!strcmp(tokens[i], "e")) {
2884 +      tokenVal[i]=M_E;
2885 +      tokens[i][0]='#';
2886 +    } else if(!strcmp(tokens[i], "ans")) {
2887 +      tokenVal[i]=ans;
2888 +      tokens[i][0]='#';
2889 +    } else if(!strcmp(tokens[i], "rand")) {
2890 +      tokenVal[i]=random()%10000;
2891 +      tokenVal[i]/=10000.0;
2892 +      tokens[i][0]='#';
2893 +    } else if(isupper(tokens[i][0])) {
2894 +      tokenVal[i]=vars[tokens[i][0]-'A'];
2895 +      tokens[i][0]='#';
2896 +    }
2897 +  }
2898 +  for(i=from;i<num&&strcmp(tokens[i], ")");i++) {
2899 +    if(!(strcmp(tokens[i], "^")&&strcmp(tokens[i], "**"))) {
2900 +      tokenVal[i-1]=pow(tokenVal[i-1], tokenVal[i+1]);
2901 +      remove(i);
2902 +      remove(i);
2903 +      i--;
2904 +    } else if(!strcmp(tokens[i], "root")) {
2905 +      tokenVal[i-1]=pow(tokenVal[i+1], 1.0/tokenVal[i-1]);
2906 +      remove(i);
2907 +      remove(i);
2908 +      i--;
2909 +    }
2910 +  }
2911 +  for(i=from;i<num&&strcmp(tokens[i], ")");i++) {
2912 +    if(!strcmp(tokens[i], "sin")) {
2913 +      tokenVal[i+1]=sin(tokenVal[i+1]*dtr);
2914 +      remove(i);
2915 +    } else if(!strcmp(tokens[i], "cos")) {
2916 +      tokenVal[i+1]=cos(tokenVal[i+1]*dtr);
2917 +      remove(i);
2918 +    } else if(!strcmp(tokens[i], "tan")) {
2919 +      tokenVal[i+1]=tan(tokenVal[i+1]*dtr);
2920 +      remove(i);
2921 +    } else if(!strcmp(tokens[i], "sec")) {
2922 +      tokenVal[i+1]=1.0/cos(tokenVal[i+1]*dtr);
2923 +      remove(i);
2924 +    } else if(!strcmp(tokens[i], "asin")) {
2925 +      tokenVal[i+1]=asin(tokenVal[i+1])/dtr;
2926 +      remove(i);
2927 +    } else if(!strcmp(tokens[i], "acos")) {
2928 +      tokenVal[i+1]=acos(tokenVal[i+1])/dtr;
2929 +      remove(i);
2930 +    } else if(!strcmp(tokens[i], "atan")) {
2931 +      tokenVal[i+1]=atan(tokenVal[i+1])/dtr;
2932 +      remove(i);
2933 +    } else if(!strcmp(tokens[i], "atanr")) {
2934 +      tokenVal[i+1]=atan2(tokenVal[i+1], tokenVal[i+2])/dtr;
2935 +      remove(i);
2936 +      remove(i+1);
2937 +    } else if(!strcmp(tokens[i], "asec")) {
2938 +      tokenVal[i+1]=acos(1.0/tokenVal[i+1])/dtr;
2939 +      remove(i);
2940 +    } else if(!strcmp(tokens[i], "sinh")) {
2941 +      tokenVal[i+1]=sinh(tokenVal[i+1])/dtr;
2942 +      remove(i);
2943 +    } else if(!strcmp(tokens[i], "cosh")) {
2944 +      tokenVal[i+1]=cosh(tokenVal[i+1])/dtr;
2945 +      remove(i);
2946 +    } else if(!strcmp(tokens[i], "tanh")) {
2947 +      tokenVal[i+1]=tanh(tokenVal[i+1])/dtr;
2948 +      remove(i);
2949 +    } else if(!strcmp(tokens[i], "hypot")) {
2950 +      tokenVal[i+1]=hypot(tokenVal[i+1], tokenVal[i+2]);
2951 +      remove(i);
2952 +      remove(i+1);
2953 +    } else if(!strcmp(tokens[i], "abs")) {
2954 +      tokenVal[i+1]=fabs(tokenVal[i+1]);
2955 +      remove(i);
2956 +    } else if(!strcmp(tokens[i], "sqrt")) {
2957 +      tokenVal[i+1]=sqrt(tokenVal[i+1]);
2958 +      remove(i);
2959 +    } else if(!strcmp(tokens[i], "log")) {
2960 +      tokenVal[i+1]=log10(tokenVal[i+1]);
2961 +      remove(i);
2962 +    } else if(!strcmp(tokens[i], "f")) {
2963 +      tokenVal[i+1]=functionF(tokenVal[i+1]);
2964 +      remove(i);
2965 +    } else if(!strcmp(tokens[i], "fi")) {
2966 +      tokenVal[i+1]=integralF(tokenVal[i+1]);
2967 +      remove(i);
2968 +    } else if(!strcmp(tokens[i], "fd")) {
2969 +      tokenVal[i+1]=derivativeF(tokenVal[i+1]);
2970 +      remove(i);
2971 +    } else if(!strcmp(tokens[i], "ln")) {
2972 +      tokenVal[i+1]=log(tokenVal[i+1]);
2973 +      remove(i);
2974 +    } else if(!strcmp(tokens[i], "ceil")) {
2975 +      tokenVal[i+1]=ceil(tokenVal[i+1]);
2976 +      remove(i);
2977 +    } else if(!strcmp(tokens[i], "floor")) {
2978 +      tokenVal[i+1]=floor(tokenVal[i+1]);
2979 +      remove(i);
2980 +    } else if(!strcmp(tokens[i], "round")) {
2981 +      tokenVal[i+1]=rint(tokenVal[i+1]);
2982 +      remove(i);
2983 +    } else if(!strcmp(tokens[i], "!")) {
2984 +      j=tokenVal[i-1];
2985 +      if(j<0) tokenVal[i-1]=asin(2.0);
2986 +      else {
2987 +       tokenVal[i-1]=1.0;
2988 +       for(;j>0;j-=1.0) tokenVal[i-1]*=j;
2989 +      }
2990 +      remove(i);
2991 +      i--;
2992 +    } else if(!strcmp(tokens[i], "int")) {
2993 +      if(tokenVal[i+1]>0.0) tokenVal[i+1]=floor(tokenVal[i+1]);
2994 +      else tokenVal[i+1]=ceil(tokenVal[i+1]);
2995 +      remove(i);
2996 +    } else if(!strcmp(tokens[i], "frac")) {
2997 +      if(tokenVal[i+1]>0.0) tokenVal[i+1]-=floor(tokenVal[i+1]);
2998 +      else tokenVal[i+1]-=ceil(tokenVal[i+1]);
2999 +      remove(i);
3000 +    }
3001 +  }
3002 +  for(i=from;i<num&&strcmp(tokens[i], ")");i++) {
3003 +    if(!strcmp(tokens[i], "*")) {
3004 +      tokenVal[i-1]*=tokenVal[i+1];
3005 +      remove(i);
3006 +      remove(i);
3007 +      i-=2;
3008 +    } else if(!strcmp(tokens[i], "/")) {
3009 +      tokenVal[i-1]/=tokenVal[i+1];
3010 +      remove(i);
3011 +      remove(i);
3012 +      i-=2;
3013 +    } else if(tokens[i][0]=='#'&&tokens[i+1][0]=='#'&&i+1<num) {
3014 +      tokenVal[i]*=tokenVal[i+1];
3015 +      remove(i+1);
3016 +      i--;
3017 +    }
3018 +  }
3019 +  for(i=from;i<num&&strcmp(tokens[i], ")");i++) {
3020 +    if(!strcmp(tokens[i], "+")) {
3021 +      tokenVal[i-1]+=tokenVal[i+1];
3022 +      remove(i);
3023 +      remove(i);
3024 +      i--;
3025 +    } else if(!strcmp(tokens[i], "-")) {
3026 +      tokenVal[i-1]-=tokenVal[i+1];
3027 +      remove(i);
3028 +      remove(i);
3029 +      i--;
3030 +    }
3031 +  }
3032 +}
3033 +
3034 +double
3035 +DALExpr::getValue(int which) {
3036 +  if(which<0||which>=num) return 0.0;
3037 +  return atof(tokens[which]);
3038 +}
3039 +
3040 +void
3041 +DALExpr::remove(int which) {
3042 +  int i;
3043 +
3044 +  for(i=which+1;i<num;i++) {
3045 +    strcpy(tokens[i-1], tokens[i]);
3046 +    tokenVal[i-1]=tokenVal[i];
3047 +  }
3048 +  num--;
3049 +}
3050 +
3051 +int
3052 +DALExpr::tType(char k) {
3053 +  if(k<=' ') return 0;
3054 +  if(islower(k)) return 3;
3055 +  if(isupper(k)) return 2;
3056 +  if(isdigit(k)||k=='_'||k=='.') return 5;
3057 +  if(k=='('||k==')') return 4;
3058 +  return 1;
3059 +}
3060 +
3061 +void
3062 +DALExpr::advanceToken(void) {
3063 +  if(!tokens[num][0]||num>=MAXTOKENS-1) return;
3064 +  if(tType(tokens[num][0])==5) {
3065 +    if(tokens[num][0]=='_') tokens[num][0]='-';
3066 +    tokenVal[num]=atof(tokens[num]);
3067 +    tokens[num][0]='#';
3068 +  }
3069 +  num++;
3070 +}
This page took 0.513215 seconds and 3 git commands to generate.