Menu

Show posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Show posts Menu

Topics - kosh

#21
Hello, Lutz

Is the bug report good here?


$ ./configure && make
gcc -m32 -Wall -pedantic -Wno-strict-aliasing -Wno-long-long -c -O2 -g -DREADLINE -DSUPPORT_UTF8 -DLINUX pcre.c
...
$ ./newlisp -n -e '(regex-comp "ほげほげ" 0x800)'    # PCRE_UTF8 = 0x800
"ERCP700..."


$ ./configure-alt && make
gcc -m32 -Wall -pedantic -Wno-long-long -Wno-strict-aliasing -O2 -c  -DNEWCONFIG pcre.c
...
$ ./newlisp -n -e '(regex-comp "ほげほげ" 0x800)'
ERR: regular expression in function regex-comp : "offset 0 this version of PCRE is not compiled with PCRE_UTF8 support"


This seems for the error to happen when SUPPORT_UTF8 is undefined when pcre.c is compiled.



---

kosh - newlisp v.10.2.16 on Ubuntu 9.10 IPv4
#22
syntax: (exec str-process)
syntax: (exec str-process [str-stdin])


Current exec function second syntax (p_exec:nl-filesys.c) is unable use a binary string.

There is caused by strlen function which treat as a NULL terminator character.



newLISP's cell string has own length. I think this problem can be avoided, if use it.



For instance, patch is here:



--- nl-filesys.orig.c. Mon Apr 19 07:29:16 2010
+++ nl-filesys.c Sun May 30 23:07:09 2010
@@ -958,10 +957,11 @@
 
 CELL * p_exec(CELL * params)
 {
-CELL * lineList;
+  CELL * cell;
 char * line;
-char * command, * data;
+  char * command;
 FILE * handle;
+  size_t nwrite;
 
 params = getString(params, &command);
 if(params == nilCell)
@@ -969,21 +969,26 @@
  if((handle = popen(command , "r")) == NULL)
  return(nilCell);
 
- lineList = getCell(CELL_EXPRESSION);
+      cell = getCell(CELL_EXPRESSION);
  while((line = readStreamLine(&readLineStream, handle)) != NULL)
- addList(lineList, stuffString(line));
+        addList(cell, stuffString(line));
 
  pclose(handle);
- return(lineList);
+      return(cell);
  }
     
-getString(params, &data);
+  /* getString(params, &data); */
+  cell = evaluateExpression(params);
+  if (cell->type != CELL_STRING)
+    return(errorProcExt(ERR_STRING_EXPECTED, params));
 
 if((handle = popen(command, "w")) == NULL)
  return(nilCell);
 
-if(fwrite(data, sizeof(char), strlen(data), handle) < strlen(data))
- return(nilCell);
+  /* if(fwrite(data, sizeof(char), strlen(data), handle) < strlen(data)) */
+  nwrite = fwrite((char *)cell->contents, sizeof(char), cell->aux -1, handle);
+  if (nwrite < (cell->aux -1))
+    return nilCell;
 
 pclose(handle);
 return(trueCell);


Now, exec function enable binary string.


[~/src/newlisp-10.2.4]$ ./newlisp -C
newLISP v.10.2.4 on Win32 IPv4, execute 'newlisp -h' for more info.

> (exec "sha1sum -" (get-url "http://www.newlisp.org/downloads/UTF-8_win32/newlisp.exe"))
db2c8f9161993bd965dd8efd75d3aa6f22f71c6f *-
true
> !curl http://www.newlisp.org/downloads/UTF-8_win32/SHA1.txt
SHA1(newlisp.dll)= 145bb1a411dd12c9e43ea052014038fd383f95ed
SHA1(newlisp.exe)= db2c8f9161993bd965dd8efd75d3aa6f22f71c6f
#23
newLISP v.10.2.4 on Linux IPv4 UTF-8, execute 'newlisp -h' for more info.

> ; "list" option works well.
> (read-file "[url]http://www.newlisp.org/example.lsp[/url]" "list")
("Last-Modified: Tue, 01 Jul 2008 13:54:24 GMTrnAccept-Ranges: bytesrnContent-Length: 58rnContent-Type: text/plainrnDate: Fri, 30 Apr 2010 13:06:12 GMTrnServer: ApachernETag: "c018d4-3a-486a3710"rnVia: 1.1 vhost.phx3.nearlyfreespeech.net:3128 (squid/2.7.STABLE7)rnConnection: closernrn"
 "; example programnn(println "Welcome to newLISP")n(exit)nn")

> ; "list debug" option returns string (not a list)
> (read-file "http://www.newlisp.org/example.lsp" "list debug")
"; example programnn(println "Welcome to newLISP")n(exit)nn"


Here is patch:


--- nl-web.c 2010-04-30 21:46:04.000000000 +0900
+++ nl-web.c~ 2010-04-19 07:29:17.000000000 +0900
@@ -349,15 +349,15 @@
     option = (char *)result->contents;    
     if(my_strnicmp(option, "header", 6) == 0)
       headRequest = TRUE;
-    if(my_strnicmp(option, "list", 4) == 0)
+    if(my_strnicmp(option, "list", 5) == 0)
       listFlag = TRUE;
     /* "debug" or "header debug" or "list-debug" options
        print all outgoing informatiopn on the console */
  if(my_strnicmp(option, "debug", 5) == 0)
       debugFlag = TRUE;
- if(my_strnicmp(option + 7, "debug", 5) == 0) /* "header debug" */
+ if(my_strnicmp(option + 7, "debug", 5) == 0)
       debugFlag = TRUE;
- if(my_strnicmp(option + 5, "debug", 5) == 0) /* "list debug" */
+ if(my_strnicmp(option + 6, "debug", 5) == 0)
       debugFlag = TRUE;
     if(params != nilCell)
         params = getInteger(params, (UINT*)&socketTimeout);
#24
Hi, Lutz.



I want to read a file in the "/proc" directory.

however `read-file' function returns empty string...


newLISP v.10.1.12 on Linux IPv4 UTF-8, execute 'newlisp -h' for more info.

> (read-file "/proc/cpuinfo")
""
> !cat /proc/cpuinfo
processor : 0
vendor_id : GenuineIntel
cpu family : 6
model : 13
...
>


Parhaps, this problem is occurd in readFile(nl-filesys.c).

That function checks the filesize, and read by filesize.



But most /proc/* file looks empty file. therefore readFile() reads 0 byte in buffer without sys-error.


> !stat /proc/cpuinfo
  File: `/proc/cpuinfo'
  Size: 0         Blocks: 0          IO Block: 1024   regular empty file
Device: 3h/3d Inode: 4026531982  Links: 1
Access: (0444/-r--r--r--)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2010-04-24 04:09:15.028358255 +0900
Modify: 2010-04-24 04:09:15.028358255 +0900
Change: 2010-04-24 04:09:15.028358255 +0900


Therefoere, I think readFile() to use malloc/realloc method is better...



--- kosh
#25
newLISP and the O.S. / some HTTP functions error
April 10, 2010, 02:54:07 PM
## 1. Cannot restore context in (load "http://...")



for example...


newLISP v.10.2.1 on Win32 IPv4 UTF-8, execute 'newlisp -h' for more info.

> (print (get-url "http://gist.github.com/362201.txt"))
;; ...
(context 'MAIN)

> (context 'Foo)
Foo> (load "http://gist.github.com/362201.txt")
> (println "Context: " (context))
Context: MAIN                                 ; context changed!
>

> (reset true)

> (write-file "/tmp/test.lsp" (get-url "http://gist.github.com/362201.txt"))
> (context 'Foo)
Foo> (load "/tmp/test.lsp")
Foo> (println "Context: " (context))
Context: Foo                                    ; restore context
Foo>




## 2. (read-file "file:///C:/...") => "No such file or directory"


> (read-file "file:///C:/Program Files/newlisp/COPYING")
nil
> (sys-error)
(2 "No such file or directory")
> (read-file "file://C:/Program Files/newlisp/COPYING")
[text]
Copyright information...
[/text]


File URI scheme - http://en.wikipedia.org/wiki/File_URI_scheme#Windows_2">http://en.wikipedia.org/wiki/File_URI_scheme#Windows_2
QuoteOr for a local file, the hostname is omitted, but the slash is not (Note the third slash):



   file:///c:/path/to/the%20file.txt
#26
newLISP v.10.1.12 on Linux IPv4 UTF-8, execute 'newlisp -h' for more info.

> (legal? "#")
nil
> (new Tree (sym "#"))                  ; make context `#'
> (set (sym "one" (sym "#")) 1)         ; `#:one' = 1
> (set (sym "two" (sym "#")) 2)         ; `#:two' = 2
> (source (sym "#"))
"n(context '#)nn(set 'one 1)nn(set 'two 2)nnn(context MAIN)nn"
> (eval-string (source (sym "#")))
ERR: missing parenthesis : "...'one 1)nn(set 'two 2)nnn(context MAI"


Therefore, `save/load' function cannot use illegal symbol too.


(save "_hash.lsp" (sym "#"))
(load "_hash.lsp")                     ;-> ERR: missing parenthesis


--- kosh
#27
newLISP and the O.S. / format bugs, etc.
December 12, 2009, 01:40:25 PM
## 1. `format' function returns a value different from `printf()'


(format "%#05x" 10)
;-> ERR: problem in format string in function format : "%#05x"

(import "libc.so.6" "printf")
(printf "%#05x" 10)
;-> 0x00a
;=> 5

(format "%c" 0)
; => "" (empty string)

(printf "%c" 0)
;-> ^@ ("00")
;=> 1


## 2. `(rand 0)' returns not integer value.
(rand 0)
;=> true


---

kosh
#28
Hello, Lutz. This is bug reports. (and first post)



`net-error' function occasionally returns a strange value when

the function given a number outside the range.


(net-error 12)                          ;=> (12 "Listen failed")
(net-error -1)                          ;=> (-1 "(null)")

(net-error 75)                          ;=> (75 "application/pdf")
(net-error 100)                         ;-> Segmentation fault


and `(sys-error 0)' return value is different from the manual.



newLISP-Manual wrote:
(sys-error 0)                           ;=> (0 "Unknown error: 0")
but program returns:
(sys-error 0)                           ;=> nil

---

kosh