From 9947e7ac63234c67a29b773922328c5d6d499fdd Mon Sep 17 00:00:00 2001 From: David Given Date: Sun, 17 Jun 2018 15:54:18 +0200 Subject: [PATCH] Added a pc.h to contain libpc prototypes; some ansification. --- lang/pc/libpc/pc.h | 18 +++++++++++++++ lang/pc/libpc/wrs.c | 54 ++++++++++++++++++++++++--------------------- lang/pc/libpc/wrz.c | 29 ++++++++++++------------ 3 files changed, 62 insertions(+), 39 deletions(-) create mode 100644 lang/pc/libpc/pc.h diff --git a/lang/pc/libpc/pc.h b/lang/pc/libpc/pc.h new file mode 100644 index 000000000..3590b25a0 --- /dev/null +++ b/lang/pc/libpc/pc.h @@ -0,0 +1,18 @@ +#ifndef PC_H +#define PC_H + +#include "pc_err.h" +#include "pc_file.h" +#include "pc_math.h" + +extern void _trp(int trapno); +extern void _wrb(int b, struct file* f); +extern void _wrs(int len, char* s, struct file* f); +extern void _wrz(char* s, struct file* f); +extern void _wsb(int w, int b, struct file* f); +extern void _wsc(int w, char c, struct file* f); +extern void _wss(int w, int len, char* s, struct file* f); +extern void _wstrin(int width, int len, char* buf, struct file* f); +extern void _wsz(int w, char* s, struct file* f); + +#endif diff --git a/lang/pc/libpc/wrs.c b/lang/pc/libpc/wrs.c index d95d0f2d8..427f0d7e6 100644 --- a/lang/pc/libpc/wrs.c +++ b/lang/pc/libpc/wrs.c @@ -18,51 +18,55 @@ /* Author: J.W. Stevenson */ -#include -#include - -extern _wf(); -extern _outcpt(); - -_wstrin(width,len,buf,f) int width,len; char *buf; struct file *f; { +#include "pc.h" +void _wstrin(int width, int len, char* buf, struct file* f) +{ _wf(f); - for (width -= len; width>0; width--) { + for (width -= len; width > 0; width--) + { *f->ptr = ' '; _outcpt(f); } - while (--len >= 0) { + while (--len >= 0) + { *f->ptr = *buf++; _outcpt(f); } } -_wsc(w,c,f) int w; char c; struct file *f; { - - if (w < 0) _trp(EWIDTH); - _wss(w,1,&c,f); +void _wsc(int w, char c, struct file* f) +{ + if (w < 0) + _trp(EWIDTH); + _wss(w, 1, &c, f); } -_wss(w,len,s,f) int w,len; char *s; struct file *f; { - - if (w < 0 || len < 0) _trp(EWIDTH); +void _wss(int w, int len, char* s, struct file* f) +{ + if (w < 0 || len < 0) + _trp(EWIDTH); if (w < len) len = w; - _wstrin(w,len,s,f); + _wstrin(w, len, s, f); } -_wrs(len,s,f) int len; char *s; struct file *f; { - if (len < 0) _trp(EWIDTH); - _wss(len,len,s,f); +void _wrs(int len, char* s, struct file* f) +{ + if (len < 0) + _trp(EWIDTH); + _wss(len, len, s, f); } -_wsb(w,b,f) int w,b; struct file *f; { +void _wsb(int w, int b, struct file* f) +{ if (b) - _wss(w,4,"true",f); + _wss(w, 4, "true", f); else - _wss(w,5,"false",f); + _wss(w, 5, "false", f); } -_wrb(b,f) int b; struct file *f; { - _wsb(5,b,f); +void _wrb(int b, struct file* f) +{ + _wsb(5, b, f); } diff --git a/lang/pc/libpc/wrz.c b/lang/pc/libpc/wrz.c index 77e304607..553b94c64 100644 --- a/lang/pc/libpc/wrz.c +++ b/lang/pc/libpc/wrz.c @@ -16,23 +16,24 @@ * */ -#include -#include +#include "pc.h" -extern _wss(); -extern _wrs(); +void _wsz(int w, char* s, struct file* f) +{ + char* p; -_wsz(w,s,f) int w; char *s; struct file *f; { - char *p; - - if (w < 0) _trp(EWIDTH); - for (p=s; *p; p++); - _wss(w,(int)(p-s),s,f); + if (w < 0) + _trp(EWIDTH); + for (p = s; *p; p++) + ; + _wss(w, (int)(p - s), s, f); } -_wrz(s,f) char *s; struct file *f; { - char *p; +void _wrz(char* s, struct file* f) +{ + char* p; - for (p=s; *p; p++); - _wrs((int)(p-s),s,f); + for (p = s; *p; p++) + ; + _wrs((int)(p - s), s, f); } -- 2.34.1