Added a pc.h to contain libpc prototypes; some ansification.

This commit is contained in:
David Given 2018-06-17 15:54:18 +02:00
parent d1671fc2e3
commit 9947e7ac63
3 changed files with 62 additions and 39 deletions

18
lang/pc/libpc/pc.h Normal file
View file

@ -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

View file

@ -18,51 +18,55 @@
/* Author: J.W. Stevenson */ /* Author: J.W. Stevenson */
#include <pc_err.h> #include "pc.h"
#include <pc_file.h>
extern _wf();
extern _outcpt();
_wstrin(width,len,buf,f) int width,len; char *buf; struct file *f; {
void _wstrin(int width, int len, char* buf, struct file* f)
{
_wf(f); _wf(f);
for (width -= len; width>0; width--) { for (width -= len; width > 0; width--)
{
*f->ptr = ' '; *f->ptr = ' ';
_outcpt(f); _outcpt(f);
} }
while (--len >= 0) { while (--len >= 0)
{
*f->ptr = *buf++; *f->ptr = *buf++;
_outcpt(f); _outcpt(f);
} }
} }
_wsc(w,c,f) int w; char c; struct file *f; { void _wsc(int w, char c, struct file* f)
{
if (w < 0) _trp(EWIDTH); if (w < 0)
_wss(w,1,&c,f); _trp(EWIDTH);
_wss(w, 1, &c, f);
} }
_wss(w,len,s,f) int w,len; char *s; struct file *f; { void _wss(int w, int len, char* s, struct file* f)
{
if (w < 0 || len < 0) _trp(EWIDTH); if (w < 0 || len < 0)
_trp(EWIDTH);
if (w < len) if (w < len)
len = w; len = w;
_wstrin(w,len,s,f); _wstrin(w, len, s, f);
} }
_wrs(len,s,f) int len; char *s; struct file *f; { void _wrs(int len, char* s, struct file* f)
if (len < 0) _trp(EWIDTH); {
_wss(len,len,s,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) if (b)
_wss(w,4,"true",f); _wss(w, 4, "true", f);
else else
_wss(w,5,"false",f); _wss(w, 5, "false", f);
} }
_wrb(b,f) int b; struct file *f; { void _wrb(int b, struct file* f)
_wsb(5,b,f); {
_wsb(5, b, f);
} }

View file

@ -16,23 +16,24 @@
* *
*/ */
#include <pc_err.h> #include "pc.h"
#include <pc_file.h>
extern _wss(); void _wsz(int w, char* s, struct file* f)
extern _wrs(); {
char* p;
_wsz(w,s,f) int w; char *s; struct file *f; { if (w < 0)
char *p; _trp(EWIDTH);
for (p = s; *p; p++)
if (w < 0) _trp(EWIDTH); ;
for (p=s; *p; p++); _wss(w, (int)(p - s), s, f);
_wss(w,(int)(p-s),s,f);
} }
_wrz(s,f) char *s; struct file *f; { void _wrz(char* s, struct file* f)
char *p; {
char* p;
for (p=s; *p; p++); for (p = s; *p; p++)
_wrs((int)(p-s),s,f); ;
_wrs((int)(p - s), s, f);
} }