devcons: simplify putstrn0()

This commit is contained in:
cinap_lenrek 2016-11-08 00:34:59 +01:00
parent 48b49361d8
commit 32dfbc7c50

View file

@ -114,9 +114,7 @@ putstrn0(char *str, int n, int usewrite)
{ {
int m; int m;
char *t; char *t;
int (*wq)(Queue*, void*, int);
if(!islo())
usewrite = 0;
/* /*
* how many different output devices do we need? * how many different output devices do we need?
@ -132,12 +130,10 @@ putstrn0(char *str, int n, int usewrite)
* if there's a serial line being used as a console, * if there's a serial line being used as a console,
* put the message there. * put the message there.
*/ */
if(kprintoq != nil && !qisclosed(kprintoq)){ wq = usewrite && islo() ? qwrite : qiwrite;
if(usewrite) if(kprintoq != nil && !qisclosed(kprintoq))
qwrite(kprintoq, str, n); (*wq)(kprintoq, str, n);
else else if(screenputs != nil)
qiwrite(kprintoq, str, n);
}else if(screenputs != nil)
screenputs(str, n); screenputs(str, n);
if(serialoq == nil){ if(serialoq == nil){
@ -149,20 +145,12 @@ putstrn0(char *str, int n, int usewrite)
t = memchr(str, '\n', n); t = memchr(str, '\n', n);
if(t != nil) { if(t != nil) {
m = t-str; m = t-str;
if(usewrite){ (*wq)(serialoq, str, m);
qwrite(serialoq, str, m); (*wq)(serialoq, "\r\n", 2);
qwrite(serialoq, "\r\n", 2);
} else {
qiwrite(serialoq, str, m);
qiwrite(serialoq, "\r\n", 2);
}
n -= m+1; n -= m+1;
str = t+1; str = t+1;
} else { } else {
if(usewrite) (*wq)(serialoq, str, n);
qwrite(serialoq, str, n);
else
qiwrite(serialoq, str, n);
break; break;
} }
} }