development release newLISP v.9.2.10

Started by Lutz, December 17, 2007, 10:39:21 AM

Previous topic - Next topic

Lutz

New functions for search and replace in nested lists. A fix for trailing slashes in the directory predicate on Win32.



Lutz



for files and changes notes see: http://newlisp.org/downloads/development/">http://newlisp.org/downloads/development/

HPW

#1
I think you meant:



http://newlisp.org/downloads/development/">http://newlisp.org/downloads/development/



(As always)

;-)
Hans-Peter

Lutz

#2
thanks for catching this, corrected in the original post.



Lutz

cormullion

#3
It's working well here (MacOS X 10.4.11 Intel). Cool new functions too!

Cyril

#4
Quote from: "cormullion"It's working well here (MacOS X 10.4.11 Intel). Cool new functions too!


I haven't looked into new functions yet, but two my scripts that I use on regular basis (shortcuts to them are even placed to my quick launch bar) are working fine. I do always test this after broken 9.2.6, but, thanks to Lutz, all of 9.2.7 - 9.2.10 was flawless.
With newLISP you can grow your lists from the right side!

Lutz

#5
... glad 9.2.10 has been fine so far, this development release is feature complete for stable release 9.3, which is due beginning January 2008.



Lutz

pjot

#6
This release compiles fine in Tru64 5.x but on 4.x I see the following (minor) issues:


Quote
Discovered Tru64 Unix, please read doc/TRU64BUILD

cc -ieee -pedantic -c -O3 -DSOLARIS -DTRU64 -DNEWLISP64 -D_POSIX_PII_SOCKET newlisp.c

cc -ieee -pedantic -c -O3 -DSOLARIS -DTRU64 -DNEWLISP64 -D_POSIX_PII_SOCKET nl-symbol.c

cc -ieee -pedantic -c -O3 -DSOLARIS -DTRU64 -DNEWLISP64 -D_POSIX_PII_SOCKET nl-math.c

cc -ieee -pedantic -c -O3 -DSOLARIS -DTRU64 -DNEWLISP64 -D_POSIX_PII_SOCKET nl-list.c

cc -ieee -pedantic -c -O3 -DSOLARIS -DTRU64 -DNEWLISP64 -D_POSIX_PII_SOCKET nl-liststr.c

cc -ieee -pedantic -c -O3 -DSOLARIS -DTRU64 -DNEWLISP64 -D_POSIX_PII_SOCKET nl-string.c

cc -ieee -pedantic -c -O3 -DSOLARIS -DTRU64 -DNEWLISP64 -D_POSIX_PII_SOCKET nl-filesys.c

cc -ieee -pedantic -c -O3 -DSOLARIS -DTRU64 -DNEWLISP64 -D_POSIX_PII_SOCKET nl-sock.c

cc: Warning: nl-sock.c, line 407: In this statement, & before array "(dest_sin.sin_zero)" is ignored. (addrarray)

        memset(&(dest_sin.sin_zero), '', sizeof(dest_sin.sin_zero));

---------------^

cc: Warning: nl-sock.c, line 407: In this statement, & before array "(dest_sin.sin_zero)" is ignored. (addrarray)

        memset(&(dest_sin.sin_zero), '', sizeof(dest_sin.sin_zero));

---------------^

cc: Warning: nl-sock.c, line 861: In this statement, & before array "(dest_sin.sin_zero)" is ignored. (addrarray)

memset(&(dest_sin.sin_zero), '', 8);

-------^

cc: Warning: nl-sock.c, line 861: In this statement, & before array "(dest_sin.sin_zero)" is ignored. (addrarray)

memset(&(dest_sin.sin_zero), '', 8);

-------^

cc: Warning: nl-sock.c, line 1191: In this statement, & before array ""

"" is ignored. (addrarray)

if(newLine) write(handle, &LINE_FEED, strlen(LINE_FEED));

--------------------------^

cc -ieee -pedantic -c -O3 -DSOLARIS -DTRU64 -DNEWLISP64 -D_POSIX_PII_SOCKET nl-import.c

cc -ieee -pedantic -c -O3 -DSOLARIS -DTRU64 -DNEWLISP64 -D_POSIX_PII_SOCKET nl-xml.c

cc -ieee -pedantic -c -O3 -DSOLARIS -DTRU64 -DNEWLISP64 -D_POSIX_PII_SOCKET nl-web.c

cc -ieee -pedantic -c -O3 -DSOLARIS -DTRU64 -DNEWLISP64 -D_POSIX_PII_SOCKET nl-matrix.c

cc -ieee -pedantic -c -O3 -DSOLARIS -DTRU64 -DNEWLISP64 -D_POSIX_PII_SOCKET nl-debug.c

cc -ieee -pedantic -c -O3 -DSOLARIS -DTRU64 -DNEWLISP64 -D_POSIX_PII_SOCKET pcre.c

cc newlisp.o nl-symbol.o nl-math.o nl-list.o nl-liststr.o nl-string.o nl-filesys.o  nl-sock.o nl-import.o nl-xml.o nl-web.o nl-matrix.o nl-debug.o pcre.o -lm -lrt -ldb -lbsd -o newlisp

strip newlisp




Also running 'qa-dot' in Tru64Unix 5.x fails for two tests:


Quote
TESTING: newlisp FINISHED WITH ERRORS:



>>>> pretty-print failed nil

>>>> rand failed nil



total time: 6679




I will investigate this later this week.



Peter

pjot

#7
The (rand) test fails because of this:
Quote
newLISP v.9.2.10 64-bit on Tru64Unix, execute 'newlisp -h' for more info.



> (set 'sum 0)

0

> (dotimes (x 1000)(inc 'sum (rand 2)))

65385830

> (and (<sum> sum 400)(list? (rand 10 100))))

nil


The 'rand' function does not work:
Quote
> (rand 2)

33878


In the sourcecode of 'nl-math.c' this is going wrong:



rnum = ((scale * random())/(RAND_MAX - 1));


From the manpage of 'random()':
Quote
  The random() function uses a nonlinear additive feedback random number gen-

  erator employing a default state array size of 31 integers to return suc-

  cessive pseudo-random numbers in the range from 0 to (2^31)-1.  The period

  of this random number generator is approximately 16*((2^31)-1).  The size

  of the state array determines the period of the random number generator.

  Increasing the state array size increases the period.




If I run this for example:

scale * random()


Then the output is 286605828.000000 or something the like. So the 'random()' function already generates a huge number. For some reason, the function bails out here:



rnum = ((scale * random())/(RAND_MAX - 1));

if(params->type == CELL_NIL)
        return(stuffInteger((UINT)rnum));


So the params->type == CELL_NIL and the huge number is returned.



Peter

pjot

#8
Phew found the cause. The value of RAND_MAX is different in Linux and Tru64Unix.



Linux:

RAND_MAX = 2147483647



Tru64Unix:

RAND_MAX = 32767





Therefore the result of the calculation ((scale * random())/(RAND_MAX - 1)) is much higher. And the test for (rand) fails.



Peter

Lutz

#9
- prettty-print



the default changed to 80 instead of 64 characters, and this has not been updated in the qa-dot and qa-comma files



- rand



had the last change in 9.2.6, this is fine MAc OS X when compiling as 64-bit version, so I don't know at the moment how to debug this for TRU64. I wonder, If I could have access to your machine?



Pehaps you insert the following code for me to debug:



long testRand; /* for debugging */

testRand = random();
printf("scale=%f  testRand=%ld RAND_MAX=%ld  scale * testRand=%fn",
    scale, testRand, RANDOM_MAX, scale * testRand);


I may have gotten wrong some of the formatting characters for TRU64.  The problem problem probably happens in the multiplication and implicit type conversions to float and back to int.



worst case we have to go back to pre 9.2.6 code for rand, let me know if 9.2.5 tests fine for rand on TRU64.



Lutz



ps: would be great to TRU64 working for 9.3 in January

pjot

#10
Hi Lutz,



Thanks for the reply. This is the result of your code:
Quote
[peter@olga]# ./newlisp

newLISP v.9.2.10 64-bit on Tru64Unix, execute 'newlisp -h' for more info.



> (rand 2)

scale=2.000000  testRand=2078917053 RAND_MAX=32767  scale * testRand=4157834106.000000

8747




Hope it helps...? Maybe the variable RAND_MAX must be redefined in 'newlisp.h'?



I do not have the sourcepackage for 9.2.5 anymore, but 9.2.0 shows:


Quote
newLISP v.9.2.0 64-bit on Tru64Unix, execute 'newlisp -h' for more info.



> (rand 2)

1


So that looks good.


Quote
ps: would be great to TRU64 working for 9.3 in January


Yes! I hope so! :-)



Peter

Lutz

#11
Thanks Peter I have redefined RAND_MAX 0x8FFFFFFF in newLISP.h conditionally for the TRU64 flavor.



Lutz

pjot

#12
Thanks, please make sure the redefinition occurs AFTER the '#include <stdio>' statement.



Compilation becomes very ugly but it works correct now:
Quote
cc -ieee -pedantic -c -O3 -DSOLARIS -DTRU64 -DNEWLISP64 -D_POSIX_PII_SOCKET newlisp.c

cc: Warning: newlisp.h, line 478: The redefinition of the macro "RAND_MAX" conflicts with a current definition because the replacement lists differ.  The redefinition is now in effect. (macroredef)

#define RAND_MAX 0x8FFFFFFF

-----------------^

cc -ieee -pedantic -c -O3 -DSOLARIS -DTRU64 -DNEWLISP64 -D_POSIX_PII_SOCKET nl-symbol.c

cc: Warning: newlisp.h, line 478: The redefinition of the macro "RAND_MAX" conflicts with a current definition because the replacement lists differ.  The redefinition is now in effect. (macroredef)

#define RAND_MAX 0x8FFFFFFF

-----------------^

cc -ieee -pedantic -c -O3 -DSOLARIS -DTRU64 -DNEWLISP64 -D_POSIX_PII_SOCKET nl-math.c

cc: Warning: newlisp.h, line 478: The redefinition of the macro "RAND_MAX" conflicts with a current definition because the replacement lists differ.  The redefinition is now in effect. (macroredef)

#define RAND_MAX 0x8FFFFFFF

-----------------^

....

[peter@olga]# ./newlisp

newLISP v.9.2.10 64-bit on Tru64Unix, execute 'newlisp -h' for more info.



> (rand 2)

1

>

[/quote]



Cheers



Peter

pjot

#13
In the headerfile 'stdlib.h' on Tru64Unix I see this:



#ifdef _BSD
#define RAND_MAX        2147483647      /* max value returned by rand   */
#else
#define RAND_MAX        32767           /* max value returned by rand   */
#endif




Now, if I add -D_BSD to the makefile, and recompile, I get this:


Quote
[peter@olga]# make

./build



Discovered Tru64 Unix, please read doc/TRU64BUILD

cc -ieee -pedantic -c -O3 -DSOLARIS -DTRU64 -DNEWLISP64 -D_POSIX_PII_SOCKET -D_BSD newlisp.c

cc: Error: newlisp.c, line 69: This declaration contains a redefinition of "opsys".  The previous declaration is at line number 440 in file newlisp.h. (redef)

int opsys = 9;

----^

cc: Error: newlisp.c, line 70: This declaration contains a redefinition of "ostype".  The previous declaration is at line number 441 in file newlisp.h. (redef)

char ostype[]="Tru64Unix";

-----^

*** Exit 1

Stop.

*** Exit 1

Stop.


Sorry for all the spam...

Lutz

#14
In the make file you can use only one definition for a flavor, if not the code may break in many more places.



I will put the define for MAX_RAND after all other includes in newlisp.h. But I think the real fix would be to fix somehow the error in the TRU64 header files, or live with the repeated warnings that MAX_RAND redefined.



Perhaps there is an option in the TRU64 compiler to suppress the macro-redefinition warning?



Lutz