Reformat.

This commit is contained in:
mycroft 1994-01-11 14:24:11 +00:00
parent bdf5bd0cf3
commit 798a4ffff3
2 changed files with 79 additions and 85 deletions

View File

@ -25,7 +25,7 @@
* any improvements or extensions that they make and grant Carnegie Mellon
* the rights to redistribute these changes.
*
* $Id: io.c,v 1.6 1993/12/23 07:12:00 cgd Exp $
* $Id: io.c,v 1.7 1994/01/11 14:24:11 mycroft Exp $
*/
#include <sys/types.h>
@ -68,54 +68,57 @@ gateA20()
/* printf - only handles %d as decimal, %c as char, %s as string */
printf(format,data)
char *format;
int data;
char *format;
int data;
{
int *dataptr = &data;
char c;
reset_twiddle();
while (c = *format++)
if (c != '%')
while (c = *format++) {
if (c != '%') {
putchar(c);
else
switch (c = *format++) {
case 'd': {
int num = *dataptr++;
char buf[10], *ptr = buf;
if (num<0) {
num = -num;
putchar('-');
}
do
*ptr++ = '0'+num%10;
while (num /= 10);
do
putchar(*--ptr);
while (ptr != buf);
break;
}
case 'x': {
int num = *dataptr++, dig;
char buf[8], *ptr = buf;
do
*ptr++ = (dig=(num&0xf)) > 9?
'a' + dig - 10 :
'0' + dig;
while (num >>= 4);
do
putchar(*--ptr);
while (ptr != buf);
break;
}
case 'c': putchar((*dataptr++)&0xff); break;
case 's': {
char *ptr = (char *)*dataptr++;
while (c = *ptr++)
putchar(c);
break;
}
continue;
}
switch (c = *format++) {
case 'd': {
int num = *dataptr++;
char buf[10], *ptr = buf;
if (num < 0) {
num = -num;
putchar('-');
}
do
*ptr++ = '0' + num % 10;
while (num /= 10);
do
putchar(*--ptr);
while (ptr != buf);
break;
}
case 'x': {
int num = *dataptr++, dig;
char buf[8], *ptr = buf;
do
*ptr++ = (dig = (num & 0xf)) > 9?
'a' + dig - 10 :
'0' + dig;
while (num >>= 4);
do
putchar(*--ptr);
while (ptr != buf);
break;
}
case 'c':
putchar((*dataptr++) & 0xff); break;
case 's': {
char *ptr = (char *)*dataptr++;
while (c = *ptr++)
putchar(c);
break;
}
}
}
}
putchar(c)
@ -129,7 +132,7 @@ getchar()
{
int c;
if ((c=getc()) == '\r')
if ((c = getc()) == '\r')
c = '\n';
if (c == '\b') {
putchar('\b');
@ -140,30 +143,31 @@ getchar()
}
gets(buf)
char *buf;
char *buf;
{
int i;
char *ptr=buf;
char *ptr = buf;
for (i = 240000; i>0; i--)
for (i = 240000; i > 0; i--)
if (ischar())
for (;;)
switch(*ptr = getchar() & 0xff) {
case '\n':
case '\r':
switch (*ptr = getchar() & 0xff) {
case '\n':
case '\r':
*ptr = '\0';
return 1;
case '\b':
if (ptr > buf) ptr--;
case '\b':
if (ptr > buf)
ptr--;
continue;
default:
default:
ptr++;
}
return 0;
}
strcmp(s1, s2)
char *s1, *s2;
char *s1, *s2;
{
while (*s1 == *s2) {
if (!*s1++)
@ -174,8 +178,8 @@ char *s1, *s2;
}
bcopy(from, to, len)
char *from, *to;
int len;
char *from, *to;
int len;
{
while (len-- > 0)
*to++ = *from++;

View File

@ -25,7 +25,7 @@
* any improvements or extensions that they make and grant Carnegie Mellon
* the rights to redistribute these changes.
*
* $Id: sys.c,v 1.3 1993/12/17 00:41:23 deraadt Exp $
* $Id: sys.c,v 1.4 1994/01/11 14:27:56 mycroft Exp $
*/
#include "boot.h"
@ -66,19 +66,16 @@ read(buffer, count)
bnum2 = fsbtodb(fs, block_map(logno)) + boff;
cnt = cnt2;
bnum = bnum2;
if ( (!off) && (size <= count))
{
if (!off && (size <= count)) {
iodest = buffer;
devread();
}
else
{
} else {
iodest = iobuf;
size -= off;
if (size > count)
size = count;
devread();
bcopy(iodest+off,buffer,size);
bcopy(iodest + off, buffer, size);
}
buffer += size;
count -= size;
@ -87,25 +84,26 @@ read(buffer, count)
}
find(path)
char *path;
char *path;
{
char *rest, ch;
int block, off, loc, ino = ROOTINO;
struct dirent *dp;
loop: iodest = iobuf;
loop:
iodest = iobuf;
cnt = fs->fs_bsize;
bnum = fsbtodb(fs,itod(fs,ino)) + boff;
bnum = fsbtodb(fs, itod(fs,ino)) + boff;
devread();
bcopy(&((struct dinode *)iodest)[ino % fs->fs_inopb],
&inode.i_din,
sizeof (struct dinode));
sizeof(struct dinode));
if (!*path)
return 1;
while (*path == '/')
path++;
if (!inode.i_size || ((inode.i_mode&IFMT) != IFDIR))
if (!inode.i_size || ((inode.i_mode & IFMT) != IFDIR))
return 0;
for (rest = path; (ch = *rest) && ch != '/'; rest++) ;
for (rest = path; (ch = *rest) && ch != '/'; rest++);
*rest = 0;
loc = 0;
do {
@ -130,11 +128,11 @@ char mapbuf[MAXBSIZE];
int mapblock = 0;
block_map(file_block)
int file_block;
int file_block;
{
if (file_block < NDADDR)
return(inode.i_db[file_block]);
if ((bnum=fsbtodb(fs, inode.i_ib[0])+boff) != mapblock) {
if ((bnum = fsbtodb(fs, inode.i_ib[0]) + boff) != mapblock) {
iodest = mapbuf;
cnt = fs->fs_bsize;
devread();
@ -151,20 +149,15 @@ openrd()
\*******************************************************/
while (*cp && *cp!='(')
cp++;
if (!*cp)
{
if (!*cp) {
cp = name;
}
else
{
if (cp++ != name)
{
} else {
if (cp++ != name) {
for (devp = devs; *devp; devp++)
if (name[0] == (*devp)[0] &&
name[1] == (*devp)[1])
break;
if (!*devp)
{
if (!*devp) {
printf("Unknown device\n");
return 1;
}
@ -174,8 +167,7 @@ openrd()
* Look inside brackets for unit number, and partition *
\*******************************************************/
if (*cp >= '0' && *cp <= '9')
if ((unit = *cp++ - '0') > 1)
{
if ((unit = *cp++ - '0') > 1) {
printf("Bad unit\n");
return 1;
}
@ -187,8 +179,7 @@ openrd()
if (!*cp)
return 1;
}
switch(maj)
{
switch(maj) {
case 1:
dosdev = unit | 0x80;
unit = 0;
@ -223,8 +214,7 @@ openrd()
/***********************************************\
* Find the actual FILE on the mounted device *
\***********************************************/
if (!find(cp))
{
if (!find(cp)) {
return 1;
}
poff = 0;