summaryrefslogtreecommitdiffabout
authorSergey Poznyakoff <gray@gnu.org>2018-08-21 08:00:53 (GMT)
committer Sergey Poznyakoff <gray@gnu.org>2018-08-21 08:00:53 (GMT)
commit6abb2548315b9db2925194e54f09f01126182f81 (patch) (side-by-side diff)
tree327743c0e929933ae38a241770d08da0433561b4
parent3adba48f117f748dfb08a0dd4cdd42f214bae93f (diff)
downloadgamma-6abb2548315b9db2925194e54f09f01126182f81.tar.gz
gamma-6abb2548315b9db2925194e54f09f01126182f81.tar.bz2
Switch to Guile 2.2
Drop support for older Guile versions.
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--configure.ac2
-rw-r--r--src/gamma-expat.c10
-rw-r--r--src/gsql_conn.c30
-rw-r--r--src/guile-sql.h2
-rw-r--r--src/mysql.c19
-rw-r--r--src/pgsql.c27
-rw-r--r--src/syslog-port.c124
7 files changed, 60 insertions, 154 deletions
diff --git a/configure.ac b/configure.ac
index 15aeb87..0695551 100644
--- a/configure.ac
+++ b/configure.ac
@@ -36,3 +36,3 @@ AM_PROG_LIBTOOL
-GINT_INIT(gint,[1.8])
+GINT_INIT(gint,[2.2.0])
diff --git a/src/gamma-expat.c b/src/gamma-expat.c
index a81d30e..cd3efaa 100644
--- a/src/gamma-expat.c
+++ b/src/gamma-expat.c
@@ -34,3 +34,3 @@ gamma_xml_parser_create(XML_Parser parser)
- gp = scm_malloc(sizeof (*gp));
+ gp = scm_gc_malloc(sizeof (*gp), "xml_parser");
gp->parser = parser;
@@ -42,3 +42,3 @@ gamma_xml_parser_create(XML_Parser parser)
-static scm_sizet
+static size_t
gamma_xml_parser_free(SCM smob)
@@ -86,3 +86,3 @@ gamma_xml_parser_print(SCM smob, SCM port, scm_print_state *pstate)
static void
-gamma_xml_parser_init()
+gamma_xml_parser_init(void)
{
@@ -98,3 +98,3 @@ gamma_xml_parser_init()
static struct gamma_expat_user_data *
-make_user_data ()
+make_user_data(void)
{
@@ -155,3 +155,3 @@ SCM_DEFINE_PUBLIC(scm_xml_primitive_make_parser, "xml-primitive-make-parser",
if (!parser)
- scm_memory_error(FUNC_NAME);
+ scm_report_out_of_memory();
XML_SetUserData(parser, make_user_data());
diff --git a/src/gsql_conn.c b/src/gsql_conn.c
index 4d53a03..64cec27 100644
--- a/src/gsql_conn.c
+++ b/src/gsql_conn.c
@@ -33,14 +33,14 @@ static long sql_connect_tag = -1;
static SCM
-sql_connect_mark (SCM connect_smob)
+sql_connect_mark(SCM connect_smob)
{
struct sql_connect *conn = (struct sql_connect *)SCM_CDR(connect_smob);
- return sql_iftab[conn->iface].mark(conn);
+ if (sql_iftab[conn->iface].mark)
+ return sql_iftab[conn->iface].mark(conn);
}
-static scm_sizet
-sql_connect_free (SCM connect_smob)
+static size_t
+sql_connect_free(SCM connect_smob)
{
- scm_sizet size = sizeof(struct sql_connect);
struct sql_connect *conn = (struct sql_connect *)SCM_CDR(connect_smob);
- size += sql_iftab[conn->iface].free(conn);
+ sql_iftab[conn->iface].free(conn);
if (conn->hostname)
@@ -52,3 +52,3 @@ sql_connect_free (SCM connect_smob)
scm_gc_free(conn, sizeof *conn, "SQL connection");
- return size;
+ return 0;
}
@@ -90,3 +90,3 @@ sql_find_iface(const char *name)
SCM
-sql_connect_create (char *name)
+sql_connect_create(char *name)
{
@@ -99,6 +99,6 @@ sql_connect_create (char *name)
- conn = scm_gc_malloc (sizeof (*conn), "sql_connect");
+ conn = scm_gc_malloc(sizeof (*conn), "sql_connect");
memset(conn, 0, sizeof *conn);
conn->iface = iface;
- SCM_RETURN_NEWSMOB (sql_connect_tag, conn);
+ SCM_RETURN_NEWSMOB(sql_connect_tag, conn);
}
@@ -106,5 +106,5 @@ sql_connect_create (char *name)
static int
-scm_is_sql_connect (SCM scm)
+scm_is_sql_connect(SCM scm)
{
- return SCM_NIMP (scm) && SCM_CAR (scm) == (SCM) sql_connect_tag;
+ return SCM_NIMP(scm) && SCM_CAR (scm) == (SCM) sql_connect_tag;
}
@@ -136,3 +136,3 @@ gamma_cvt_iface(SCM inval, void *outval, const char *func_name)
-SCM_DEFINE_PUBLIC (sql_open_connection, "sql-open-connection", 1, 0, 0,
+SCM_DEFINE_PUBLIC(sql_open_connection, "sql-open-connection", 1, 0, 0,
(SCM param),
@@ -187,3 +187,3 @@ SCM_DEFINE_PUBLIC (sql_open_connection, "sql-open-connection", 1, 0, 0,
-SCM_DEFINE_PUBLIC (sql_close_connection, "sql-close-connection", 1, 0, 0,
+SCM_DEFINE_PUBLIC(sql_close_connection, "sql-close-connection", 1, 0, 0,
(SCM conn),
@@ -200,3 +200,3 @@ SCM_DEFINE_PUBLIC (sql_close_connection, "sql-close-connection", 1, 0, 0,
-SCM_DEFINE_PUBLIC (sql_query, "sql-query", 2, 0, 0,
+SCM_DEFINE_PUBLIC(sql_query, "sql-query", 2, 0, 0,
(SCM conn, SCM query),
diff --git a/src/guile-sql.h b/src/guile-sql.h
index 926aa74..f656fd4 100644
--- a/src/guile-sql.h
+++ b/src/guile-sql.h
@@ -41,3 +41,3 @@ struct sql_iface {
SCM (*mark) (struct sql_connect *);
- scm_sizet (*free) (struct sql_connect *);
+ size_t (*free) (struct sql_connect *);
SCM (*connect) (SCM parmlist, const char *func_name);
diff --git a/src/mysql.c b/src/mysql.c
index 1310212..dcc1847 100644
--- a/src/mysql.c
+++ b/src/mysql.c
@@ -23,9 +23,3 @@
-static SCM
-s_mysql_mark(struct sql_connect *conn)
-{
- return SCM_BOOL_F;
-}
-
-static scm_sizet
+static size_t
s_mysql_free(struct sql_connect *conn)
@@ -33,6 +27,5 @@ s_mysql_free(struct sql_connect *conn)
MYSQL *mysql = (MYSQL*) conn->data;
- if (!mysql)
- return 0;
- mysql_close(mysql);
- return sizeof(MYSQL);
+ if (mysql)
+ mysql_close(mysql);
+ return 0;
}
@@ -40,3 +33,3 @@ s_mysql_free(struct sql_connect *conn)
static SCM
-s_mysql_connect (SCM parmlist, const char *func_name)
+s_mysql_connect(SCM parmlist, const char *func_name)
{
@@ -227,3 +220,3 @@ struct sql_iface mysql_iface = {
"mysql",
- s_mysql_mark,
+ NULL, /* mark */
s_mysql_free,
diff --git a/src/pgsql.c b/src/pgsql.c
index c5cf51e..1421c40 100644
--- a/src/pgsql.c
+++ b/src/pgsql.c
@@ -23,9 +23,3 @@
-static SCM
-s_pgsql_mark(struct sql_connect *conn)
-{
- return SCM_BOOL_F;
-}
-
-static scm_sizet
+static size_t
s_pgsql_free(struct sql_connect *conn)
@@ -33,6 +27,5 @@ s_pgsql_free(struct sql_connect *conn)
PGconn *pgconn = (PGconn*) conn->data;
- if (!pgconn)
- return 0;
- PQfinish(pgconn);
- return sizeof(pgconn);
+ if (pgconn)
+ PQfinish(pgconn);
+ return 0;
}
@@ -40,3 +33,3 @@ s_pgsql_free(struct sql_connect *conn)
static SCM
-s_pgsql_connect (SCM parmlist, const char *func_name)
+s_pgsql_connect(SCM parmlist, const char *func_name)
{
@@ -170,6 +163,6 @@ s_pgsql_close(struct sql_connect *conn)
PGconn *pgconn = (PGconn*) conn->data;
- if (!pgconn)
- return;
- PQfinish(pgconn);
- conn->data = NULL;
+ if (pgconn) {
+ PQfinish(pgconn);
+ conn->data = NULL;
+ }
}
@@ -178,3 +171,3 @@ struct sql_iface pgsql_iface = {
"pgsql",
- s_pgsql_mark,
+ NULL, /* mark */
s_pgsql_free,
diff --git a/src/syslog-port.c b/src/syslog-port.c
index 4b27ef9..4388c10 100644
--- a/src/syslog-port.c
+++ b/src/syslog-port.c
@@ -30,3 +30,3 @@ typedef off_t scm_t_off;
#define GAMMA_SYSLOG_PORT_BUFSIZE 1024
-static scm_t_bits scm_tc16_syslog_port;
+static scm_t_port_type *scm_syslog_port_type;
struct _gamma_syslog_port {
@@ -39,21 +39,8 @@ _make_syslog_port(int prio)
struct _gamma_syslog_port *dp;
- SCM port;
- scm_port *pt;
- dp = scm_gc_malloc (sizeof (struct _gamma_syslog_port), "syslog-port");
+ dp = scm_gc_typed_calloc (struct _gamma_syslog_port);
dp->prio = prio;
-
- port = scm_new_port_table_entry(scm_tc16_syslog_port);
- pt = SCM_PTAB_ENTRY(port);
- pt->rw_random = 0;
- pt->write_buf = scm_gc_malloc(GAMMA_SYSLOG_PORT_BUFSIZE,
- "syslog port buffer");
- pt->write_pos = pt->write_buf;
- pt->write_buf_size = GAMMA_SYSLOG_PORT_BUFSIZE;
- pt->write_end = pt->write_buf + pt->write_buf_size;
- SCM_SET_CELL_TYPE(port,
- (scm_tc16_syslog_port |
- SCM_OPN | SCM_WRTNG | SCM_BUFLINE));
- SCM_SETSTREAM(port, dp);
- return port;
+ return scm_c_make_port(scm_syslog_port_type,
+ SCM_OPN | SCM_WRTNG | SCM_BUFLINE,
+ (scm_t_bits) dp);
}
@@ -62,38 +49,3 @@ _make_syslog_port(int prio)
-static SCM
-_syslog_port_mark(SCM port)
-{
- return SCM_BOOL_F;
-}
-
static void
-_syslog_port_flush(SCM port)
-{
- struct _gamma_syslog_port *dp = SYSLOG_PORT(port);
- scm_port *pt = SCM_PTAB_ENTRY(port);
- size_t size = pt->write_pos - pt->write_buf;
- unsigned char *nl = memchr(pt->write_buf, '\n', size);
- int wrsize;
-
- if (!nl)
- return;
-
- wrsize = nl - pt->write_buf;
-
- *nl = 0;
- syslog (dp->prio, "%s", (char *) pt->write_buf);
- *nl = '\n';
-
- if (wrsize < size) {
- size_t write_start;
-
- nl++;
- write_start = pt->write_pos - nl;
- memmove(pt->write_buf, nl, write_start);
- pt->write_pos = pt->write_buf + write_start;
- } else
- pt->write_pos = pt->write_buf;
-}
-
-static int
_syslog_port_close(SCM port)
@@ -101,14 +53,8 @@ _syslog_port_close(SCM port)
struct _gamma_syslog_port *dp = SYSLOG_PORT(port);
-
- if (dp) {
- _syslog_port_flush(port);
- SCM_SETSTREAM(port, NULL);
- scm_gc_free(dp, sizeof(struct _gamma_syslog_port),
- "syslog-port");
- }
- return 0;
+ /* nothing */
}
-static scm_sizet
+static size_t
_syslog_port_free(SCM port)
+/* FIXME: basically, a no-op */
{
@@ -118,35 +64,11 @@ _syslog_port_free(SCM port)
-static int
-_syslog_port_fill_input(SCM port)
-{
- return EOF;
-}
-
-static void
-_syslog_port_write(SCM port, const void *data, size_t size)
+static size_t
+_syslog_port_write(SCM port, SCM src, size_t start, size_t count)
{
- scm_port *pt = SCM_PTAB_ENTRY (port);
- size_t space = pt->write_end - pt->write_pos;
- if (space < size) {
- size_t start = pt->write_pos - pt->write_buf;
- size_t new_size = pt->write_buf_size;
-
- do {
- /*FIXME*/
- new_size *= 2;
- } while (new_size - start < size);
-
- pt->write_buf = scm_gc_realloc(pt->write_buf,
- pt->write_buf_size,
- new_size,
- "syslog port buffer");
- pt->write_buf_size = new_size;
- pt->write_end = pt->write_buf + pt->write_buf_size;
- pt->write_pos = pt->write_buf + start;
- }
- memcpy(pt->write_pos, data, size);
- pt->write_pos += size;
-
- if (memchr (data, '\n', size))
- _syslog_port_flush(port);
+ struct _gamma_syslog_port *dp = SYSLOG_PORT(port);
+ syslog(dp->prio, "%*.*s",
+ (int) count,
+ (int) count,
+ SCM_BYTEVECTOR_CONTENTS(src) + start);
+ return count;
}
@@ -182,11 +104,9 @@ _gamma_init_syslog_port()
{
- scm_tc16_syslog_port = scm_make_port_type("syslog-port",
- _syslog_port_fill_input,
+ scm_syslog_port_type = scm_make_port_type("syslog-port",
+ NULL,
_syslog_port_write);
- scm_set_port_mark(scm_tc16_syslog_port, _syslog_port_mark);
- scm_set_port_free(scm_tc16_syslog_port, _syslog_port_free);
- scm_set_port_print(scm_tc16_syslog_port, _syslog_port_print);
- scm_set_port_flush(scm_tc16_syslog_port, _syslog_port_flush);
- scm_set_port_close(scm_tc16_syslog_port, _syslog_port_close);
- scm_set_port_seek(scm_tc16_syslog_port, _syslog_port_seek);
+ scm_set_port_free(scm_syslog_port_type, _syslog_port_free);
+ scm_set_port_print(scm_syslog_port_type, _syslog_port_print);
+ scm_set_port_close(scm_syslog_port_type, _syslog_port_close);
+ scm_set_port_seek(scm_syslog_port_type, _syslog_port_seek);
#include <syslog-port.x>

Return to:

Send suggestions and report system problems to the System administrator.