changeset: 67:ed249baf7915
tag: tip
user: Kris Maglione <jg_AT_suckless.org>
date: Sun Jul 01 16:10:21 2007 -0400
summary: Fix issues. Add ixp_print and ixp_vprint.
diff -r d1135639e634 -r ed249baf7915 cmd/Makefile
--- a/cmd/Makefile Sun Jul 01 07:51:34 2007 -0400
+++ b/cmd/Makefile Sun Jul 01 16:10:21 2007 -0400
@@ -4,6 +4,6 @@ include ${ROOT}/mk/ixp.mk
TARG = ixpc
OBJ = ixpc
-LIB = ${ROOT}/libixp/libixp.a
+LIB = ${ROOT}/lib/libixp.a
include ${ROOT}/mk/one.mk
diff -r d1135639e634 -r ed249baf7915 include/ixp.h
--- a/include/ixp.h Sun Jul 01 07:51:34 2007 -0400
+++ b/include/ixp.h Sun Jul 01 16:10:21 2007 -0400
@@ -397,6 +397,7 @@ struct IxpThread {
extern IxpThread *ixp_thread;
extern int (*ixp_vsnprint)(char*, int, char*, va_list);
+extern char* (*ixp_vsmprint)(char*, va_list);
/* thread_*.c */
int ixp_taskinit(void);
@@ -416,6 +417,8 @@ long ixp_pread(IxpCFid *f, void *buf, lo
long ixp_pread(IxpCFid *f, void *buf, long count, vlong offset);
long ixp_pwrite(IxpCFid *f, void *buf, long count, vlong offset);
int ixp_close(IxpCFid *f);
+int ixp_print(IxpCFid *f, char *fmt, ...);
+int ixp_vprint(IxpCFid *f, char *fmt, va_list ap);
/* convert.c */
void ixp_pu8(IxpMsg *msg, uchar *val);
diff -r d1135639e634 -r ed249baf7915 libixp/client.c
--- a/libixp/client.c Sun Jul 01 07:51:34 2007 -0400
+++ b/libixp/client.c Sun Jul 01 16:10:21 2007 -0400
@@ -425,7 +425,7 @@ _pwrite(IxpCFid *f, void *buf, long coun
fcall.type = TWrite;
fcall.fid = f->fid;
fcall.offset = f->offset;
- fcall.data = (uchar*)buf + len;
+ fcall.data = buf + len;
fcall.count = n;
if(dofcall(f->client, &fcall) == 0)
return -1;
@@ -462,3 +462,29 @@ ixp_pwrite(IxpCFid *f, void *buf, long c
return n;
}
+int
+ixp_vprint(IxpCFid *f, char *fmt, va_list ap) {
+ char *buf;
+ int n;
+
+ buf = ixp_vsmprint(fmt, ap);
+ if(buf == nil)
+ return -1;
+
+ n = ixp_write(f, buf, strlen(buf));
+ free(buf);
+ return n;
+}
+
+int
+ixp_print(IxpCFid *f, char *fmt, ...) {
+ va_list ap;
+ int n;
+
+ va_start(ap, fmt);
+ n = ixp_vprint(f, fmt, ap);
+ va_end(ap);
+
+ return n;
+}
+
diff -r d1135639e634 -r ed249baf7915 libixp/convert.c
--- a/libixp/convert.c Sun Jul 01 07:51:34 2007 -0400
+++ b/libixp/convert.c Sun Jul 01 16:10:21 2007 -0400
@@ -133,7 +133,7 @@ ixp_pstrings(IxpMsg *msg, ushort *num, c
if(msg->mode == MsgUnpack) {
memcpy(s, msg->pos, len);
- strings[i] = s;
+ strings[i] = (char*)s;
s += len;
msg->pos += len;
*s++ = '\0';
diff -r d1135639e634 -r ed249baf7915 libixp/error.c
--- a/libixp/error.c Sun Jul 01 07:51:34 2007 -0400
+++ b/libixp/error.c Sun Jul 01 16:10:21 2007 -0400
@@ -1,10 +1,33 @@
#include <errno.h>
#include <stdarg.h>
#include <stdio.h>
+#include <stdlib.h>
#include <string.h>
#include "ixp_local.h"
-int (*ixp_vsnprint)(char*, int, char*, va_list);
+static int
+_vsnprint(char *buf, int n, char *fmt, va_list ap) {
+ return vsnprintf(buf, n, fmt, ap);
+}
+
+static char*
+_vsmprint(char *fmt, va_list ap) {
+ va_list al;
+ char *buf = "";
+ int n;
+
+ va_copy(al, ap);
+ n = snprintf(buf, 0, fmt, al);
+ va_end(al);
+
+ buf = malloc(++n);
+ if(buf)
+ snprintf(buf, n, fmt, ap);
+ return buf;
+}
+
+int (*ixp_vsnprint)(char*, int, char*, va_list) = _vsnprint;
+char* (*ixp_vsmprint)(char*, va_list) = _vsmprint;
/* Approach to errno handling taken from Plan 9 Port. */
enum {
@@ -44,10 +67,7 @@ werrstr(char *fmt, ...) {
va_list ap;
va_start(ap, fmt);
- if(ixp_vsnprint)
- ixp_vsnprint(tmp, sizeof(tmp), fmt, ap);
- else
- vsnprintf(tmp, sizeof(tmp), fmt, ap);
+ ixp_vsnprint(tmp, sizeof(tmp), fmt, ap);
va_end(ap);
strncpy(thread->errbuf(), tmp, IXP_ERRMAX);
errno = EPLAN9;
diff -r d1135639e634 -r ed249baf7915 libixp/message.c
--- a/libixp/message.c Sun Jul 01 07:51:34 2007 -0400
+++ b/libixp/message.c Sun Jul 01 16:10:21 2007 -0400
@@ -169,7 +169,7 @@ ixp_pfcall(IxpMsg *msg, Fcall *fcall) {
uint
ixp_fcall2msg(IxpMsg *msg, Fcall *fcall) {
- int size;
+ uint size;
msg->end = msg->data + msg->size;
msg->pos = msg->data + SDWord;
diff -r d1135639e634 -r ed249baf7915 libixp_pthread/thread_pthread.c
--- a/libixp_pthread/thread_pthread.c Sun Jul 01 07:51:34 2007 -0400
+++ b/libixp_pthread/thread_pthread.c Sun Jul 01 16:10:21 2007 -0400
@@ -3,7 +3,6 @@
#include <stdlib.h>
#include <unistd.h>
#include "ixp_local.h"
-#include "ixp_pthread.h"
static IxpThread ixp_pthread;
static pthread_key_t errstr_k;
diff -r d1135639e634 -r ed249baf7915 libixp_rubythread/thread_ruby.c
--- a/libixp_rubythread/thread_ruby.c Sun Jul 01 07:51:34 2007 -0400
+++ b/libixp_rubythread/thread_ruby.c Sun Jul 01 16:10:21 2007 -0400
@@ -3,7 +3,6 @@
#include <unistd.h>
#include <ruby.h>
#include "ixp_local.h"
-#include "ixp_rubythread.h"
static IxpThread ixp_rthread;
static char RWLock[];
diff -r d1135639e634 -r ed249baf7915 libixp_task/thread_task.c
--- a/libixp_task/thread_task.c Sun Jul 01 07:51:34 2007 -0400
+++ b/libixp_task/thread_task.c Sun Jul 01 16:10:21 2007 -0400
@@ -3,7 +3,6 @@
#include <unistd.h>
#include <task.h>
#include "ixp_local.h"
-#include "ixp_task.h"
static IxpThread ixp_task;
diff -r d1135639e634 -r ed249baf7915 mk/lib.mk
--- a/mk/lib.mk Sun Jul 01 07:51:34 2007 -0400
+++ b/mk/lib.mk Sun Jul 01 16:10:21 2007 -0400
@@ -18,8 +18,8 @@ printinstall:
echo ' Lib: ${LIBDIR}'
${LIB}: ${OFILES}
- @echo AR $$($(ROOT)/util/cleanname $(BASE)/$@)
- @${AR} $@ ${OFILES}
- @${RANLIB} $@
+ echo AR $$($(ROOT)/util/cleanname $(BASE)/$@)
+ mkdir ${ROOT}/lib 2>/dev/null || true
+ ${AR} $@ ${OFILES}
include ${ROOT}/mk/common.mk
diff -r d1135639e634 -r ed249baf7915 util/compile
--- a/util/compile Sun Jul 01 07:51:34 2007 -0400
+++ b/util/compile Sun Jul 01 16:10:21 2007 -0400
@@ -12,8 +12,9 @@ status=$?
status=$?
base=$(echo $BASE | sed 's/,/\\,/g')
+re='\([^[:space:]/]*\..:[0-9]\)'
-cat $xtmp | sed "s,^[^/][^:]*\.c:,$base&,g" |
+cat $xtmp | sed "s,^$re,$base&,g; s,\([[:space:]]\)$re,\1$base\2,g" |
egrep -v ': error: .Each undeclared identifier|: error: for each function it appears|is dangerous, better use|is almost always misused|: In function |: At top level:|support .long long.|use of C99 long long|ISO C forbids conversion' |
sed 's/ .first use in this function.$//; s/\"\([^\"][^\"]*\)\", line \([0-9][0-9]*\)/\1:\2/g' |
uniq 1>&2
Received on Sun Jul 01 2007 - 22:11:19 UTC
This archive was generated by hypermail 2.2.0 : Sun Jul 13 2008 - 15:57:26 UTC