ack/lang/basic/lib/print.c

82 lines
1.1 KiB
C
Raw Normal View History

#include <stdlib.h>
#include <stdio.h>
#include "bc_string.h"
#include "bc_io.h"
1984-11-29 14:22:02 +00:00
1994-06-24 11:31:16 +00:00
/* $Id$ */
1984-11-29 14:22:02 +00:00
/* Here all routine to generate terminal oriented output is located */
_qstmark()
{
/* prompt for terminal input */
putchar('?');
}
_nl()
{
_asschn();
_outnl();
}
_prinum(i)
int i;
{
char buffer[40];
_asschn();
if(i>=0)
sprintf(buffer," %d ",i);
else sprintf(buffer,"-%d ",-i);
_out(buffer);
}
_str(f,buffer)
double f;
char *buffer;
{
register char *c = buffer;
int eformat = 0;
1984-11-29 14:22:02 +00:00
if( f>=0){
if( f> 1.0e8) {
eformat = 1;
1984-11-29 14:22:02 +00:00
sprintf(buffer," %e",f);
}
1984-11-29 14:22:02 +00:00
else sprintf(buffer," %f",f);
c++;
}else {
if(-f> 1.0e8) {
eformat = 1;
1984-11-29 14:22:02 +00:00
sprintf(buffer,"-%e",-f);
}
1984-11-29 14:22:02 +00:00
else sprintf(buffer,"-%f",-f);
}
if (! eformat) {
for( ; *c && *c!= ' ';c++) ;
c--;
while( c>buffer && *c== '0')
{
*c= 0;c--;
}
if( *c=='.') *c=0;
1984-11-29 14:22:02 +00:00
}
}
_prfnum(f)
double f;
{
/* BASIC strings trailing zeroes */
char buffer[100];
char *c;
_asschn();
c= buffer;
_str(f,c);
1988-07-04 11:44:03 +00:00
strcat(buffer," ");
1984-11-29 14:22:02 +00:00
_out(buffer);
}
_prstr(str)
String *str;
{
_asschn();
if( str==0) _out("<null>");
else _out(str->strval);
}