shithub: femtolisp

Download patch

ref: 8d7576250d2dbb5e95cba9cfba453e6ae75fab98
parent: b7f08e854fa7b693837c3c2c2d141954c973117d
author: JeffBezanson <[email protected]>
date: Sun May 2 14:28:53 EDT 2010

porting over some minor changes to LLT


--- a/llt/dump.c
+++ b/llt/dump.c
@@ -10,7 +10,7 @@
   display a given number of bytes from a buffer, with the first
   address label being startoffs
 */
-void hexdump(ios_t *dest, char *buffer, size_t len, size_t startoffs)
+void hexdump(ios_t *dest, const char *buffer, size_t len, size_t startoffs)
 {
     size_t offs=0;
     size_t i, pos;
--- a/llt/hashing.c
+++ b/llt/hashing.c
@@ -3,7 +3,6 @@
 */
 #include <stdlib.h>
 #include <stdio.h>
-#include <stdarg.h>
 #include <math.h>
 #include "ieee754.h"
 #include "dtypes.h"
@@ -62,7 +61,7 @@
 
 #include "lookup3.c"
 
-u_int64_t memhash(char* buf, size_t n)
+u_int64_t memhash(const char* buf, size_t n)
 {
     u_int32_t c=0xcafe8881, b=0x4d6a087c;
 
@@ -70,7 +69,7 @@
     return (u_int64_t)c | (((u_int64_t)b)<<32);
 }
 
-u_int32_t memhash32(char* buf, size_t n)
+u_int32_t memhash32(const char* buf, size_t n)
 {
     u_int32_t c=0xcafe8881, b=0x4d6a087c;
 
--- a/llt/hashing.h
+++ b/llt/hashing.h
@@ -10,7 +10,7 @@
 #else
 #define inthash int32hash
 #endif
-u_int64_t memhash(char* buf, size_t n);
-u_int32_t memhash32(char* buf, size_t n);
+u_int64_t memhash(const char* buf, size_t n);
+u_int32_t memhash32(const char* buf, size_t n);
 
 #endif
--- a/llt/ios.c
+++ b/llt/ios.c
@@ -371,7 +371,7 @@
         wrote = _write_grow(s, data, n);
     }
     else if (s->bm == bm_none) {
-        int result = _os_write_all(s->fd, data, n, &wrote);
+        _os_write_all(s->fd, data, n, &wrote);
         return wrote;
     }
     else if (n <= space) {
@@ -395,7 +395,7 @@
         s->state = bst_wr;
         ios_flush(s);
         if (n > MOST_OF(s->maxsize)) {
-            int result = _os_write_all(s->fd, data, n, &wrote);
+            _os_write_all(s->fd, data, n, &wrote);
             return wrote;
         }
         return ios_write(s, data, n);
@@ -414,11 +414,14 @@
         return s->bpos;
     }
     // TODO
+    return 0;
 }
 
 off_t ios_seek_end(ios_t *s)
 {
     s->_eof = 1;
+    // TODO
+    return 0;
 }
 
 off_t ios_skip(ios_t *s, off_t offs)
@@ -425,6 +428,8 @@
 {
     if (offs < 0)
         s->_eof = 0;
+    // TODO
+    return 0;
 }
 
 off_t ios_pos(ios_t *s)
@@ -879,7 +884,6 @@
     int c;
     size_t sz;
     char c0;
-    char buf[8];
 
     c = ios_peekc(s);
     if (c == IOS_EOF)
@@ -913,7 +917,9 @@
     }
 }
 
-int ios_vprintf(ios_t *s, char *format, va_list args)
+int vasprintf(char **strp, const char *fmt, va_list ap);
+
+int ios_vprintf(ios_t *s, const char *format, va_list args)
 {
     char *str=NULL;
     int c;
@@ -944,7 +950,7 @@
     return c;
 }
 
-int ios_printf(ios_t *s, char *format, ...)
+int ios_printf(ios_t *s, const char *format, ...)
 {
     va_list args;
     int c;
--- a/llt/ios.h
+++ b/llt/ios.h
@@ -1,6 +1,8 @@
 #ifndef __IOS_H_
 #define __IOS_H_
 
+#include <stdarg.h>
+
 // this flag controls when data actually moves out to the underlying I/O
 // channel. memory streams are a special case of this where the data
 // never moves out.
@@ -103,10 +105,10 @@
 int ios_putint(ios_t *s, int n);
 int ios_pututf8(ios_t *s, uint32_t wc);
 int ios_putstringz(ios_t *s, char *str, bool_t do_write_nulterm);
-int ios_printf(ios_t *s, char *format, ...);
-int ios_vprintf(ios_t *s, char *format, va_list args);
+int ios_printf(ios_t *s, const char *format, ...);
+int ios_vprintf(ios_t *s, const char *format, va_list args);
 
-void hexdump(ios_t *dest, char *buffer, size_t len, size_t startoffs);
+void hexdump(ios_t *dest, const char *buffer, size_t len, size_t startoffs);
 
 /* high-level stream functions - input */
 int ios_getnum(ios_t *s, char *data, uint32_t type);
--- a/llt/timefuncs.c
+++ b/llt/timefuncs.c
@@ -108,7 +108,7 @@
 
 #if defined(LINUX) || defined(MACOSX)
 extern char *strptime(const char *s, const char *format, struct tm *tm);
-double parsetime(char *str)
+double parsetime(const char *str)
 {
     char *fmt = "%c"; /* needed to suppress GCC warning */
     char *res;
--- a/llt/timefuncs.h
+++ b/llt/timefuncs.h
@@ -4,7 +4,7 @@
 u_int64_t i64time();
 double clock_now();
 void timestring(double seconds, char *buffer, size_t len);
-double parsetime(char *str);
+double parsetime(const char *str);
 void sleep_ms(int ms);
 void timeparts(int32_t *buf, double t);
 
--- a/llt/utf8.c
+++ b/llt/utf8.c
@@ -240,6 +240,8 @@
     return count;
 }
 
+int wcwidth(wchar_t c);
+
 size_t u8_strwidth(const char *s)
 {
     u_int32_t ch;