With gcc-14 enables "-Wimplicit-function-declaration" by default,
we get this error when building with GCL:

/tmp/fricas-1.3.11/src/lisp/fricas-lisp.c: In function ‘sock_get_string_buf_wrapper’: /tmp/fricas-1.3.11/src/lisp/fricas-lisp.c:703:10: error: implicit declaration of function ‘sock_get_string_buf’; did you mean ‘sock_send_string_len’? [-Wimplicit-function-declaration]
  703 |   return sock_get_string_buf(i, x->st.st_self, j); }
      |          ^~~~~~~~~~~~~~~~~~~
      |          sock_send_string_len


We need to add a declaration in the "clines".

But to get the return type match, I also need to change the
return type of "sock_get_string_buf" to int.
Its return value is currently ignored.

Writing this patch makes me realize that we need to improve
"sock_get_string_buf" more:

First, there's discrepancy between GCL and other Lisps:
if the string is bigger than buffer, GCL gives an error,
while other Lisps fill the buffer with part of the string.
But in this case the following operations with be messed up.
Because there is no loop to clear the socket.

Currently we use a buffer of size 10000, hoping it to be big
enough.  This should be improved later.

- Qian

--
You received this message because you are subscribed to the Google Groups "FriCAS - 
computer algebra system" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to fricas-devel+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/fricas-devel/8e807b39-df00-4043-8cc6-4db5eabb5b3e%40gmail.com.
diff --git a/src/include/sockio-c.H1 b/src/include/sockio-c.H1
index 2f90fe56..80c0838e 100644
--- a/src/include/sockio-c.H1
+++ b/src/include/sockio-c.H1
@@ -25,7 +25,7 @@ extern int send_strings(Sock *, char * *, int);
 extern int sock_send_strings(int, char * *, int);
 extern char * sock_get_string(int);
 extern char * get_string_buf(Sock *, char *, int);
-extern char * sock_get_string_buf(int, char *, int);
+extern int sock_get_string_buf(int, char *, int);
 extern int get_strings(Sock *, char * *, int);
 extern int sock_get_strings(int, char * *, int);
 extern int send_float(Sock *, double);
diff --git a/src/lib/sockio-c.c b/src/lib/sockio-c.c
index e89163ce..d8a62999 100644
--- a/src/lib/sockio-c.c
+++ b/src/lib/sockio-c.c
@@ -522,12 +522,12 @@ get_string_buf(Sock *sock, char *buf, int buf_len)
     }
 }
 
-char *
+int
 sock_get_string_buf(int purpose, char * buf, int buf_len)
 {
   if (accept_if_needed(purpose) != -1)
-    return get_string_buf(purpose_table[purpose], buf, buf_len);
-  return NULL;
+    return NULL != get_string_buf(purpose_table[purpose], buf, buf_len);
+  return 0;
 }
 
 int
diff --git a/src/lisp/fricas-lisp.lisp b/src/lisp/fricas-lisp.lisp
index 4e7a2222..1c863854 100644
--- a/src/lisp/fricas-lisp.lisp
+++ b/src/lisp/fricas-lisp.lisp
@@ -643,7 +643,7 @@ with this hack and will try to convince the GCL crowd to fix this.
        (sig int))
 
 #-:gcl
-(fricas-foreign-call sock_get_string_buf "sock_get_string_buf" char-*
+(fricas-foreign-call sock_get_string_buf "sock_get_string_buf" int
        (purpose int)
        (buf char-*)
        (len int))
@@ -657,7 +657,9 @@ with this hack and will try to convince the GCL crowd to fix this.
 ;; string with data read from connection, therefore needs address of
 ;; actual string buffer. We use 'sock_get_string_buf_wrapper' to
 ;; resolve the problem
-(SI::clines "int sock_get_string_buf_wrapper(int i, object x, int j)"
+(SI::clines
+    "int sock_get_string_buf(int, char *, int);"
+    "int sock_get_string_buf_wrapper(int i, object x, int j)"
     "{ if (type_of(x)!=t_string) FEwrong_type_argument(sLstring,x);"
     "  if (x->st.st_fillp<j)"
     "    FEerror(\"string too small in sock_get_string_buf_wrapper\",0);"

Reply via email to