Changeset 4164 for trunk/src/win32k/dev16/vprntf16.c
- Timestamp:
- Sep 2, 2000, 11:08:23 PM (25 years ago)
- File:
-
- 1 edited
-
trunk/src/win32k/dev16/vprntf16.c (modified) (11 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/win32k/dev16/vprntf16.c
r2905 r4164 1 /* $Id: vprntf16.c,v 1. 2 2000-02-26 17:49:28bird Exp $1 /* $Id: vprntf16.c,v 1.3 2000-09-02 21:07:56 bird Exp $ 2 2 * 3 3 * vprintf and printf - 16-bit. … … 36 36 #include <os2.h> 37 37 38 #include "devSegDf.h" /* Win32k segment definitions. */ 39 #include "dev16.h" 38 40 #include "vprntf16.h" 39 41 #ifdef RING0 … … 41 43 #include "conio.h" 42 44 #endif 43 #include "dev16.h"44 45 45 46 /******************************************************************************* 46 47 * Global Variables * 47 48 *******************************************************************************/ 49 static char chReturn = '\r'; 48 50 static char chNewLine = '\n'; 49 static char chReturn = '\r';51 static char chReturnWithNewLine[2] = "\r\n"; 50 52 51 53 /******************************************************************************* … … 217 219 * @param args Argument list. 218 220 */ 219 int vprintf16(const char *pszFormat, va_list args)221 int FAR vprintf16(const char *pszFormat, va_list args) 220 222 { 221 223 int cch = 0; … … 327 329 char *pszStr = va_arg(args, char*); 328 330 329 if (pszStr < (char*)0x10000)331 if (pszStr == NULL) 330 332 pszStr = "<NULL>"; 331 333 cchStr = _strnlen(pszStr, (unsigned)cchPrecision); … … 391 393 * @param ... Optional parameters. 392 394 */ 393 int printf16(const char *pszFormat, ...)395 int FAR printf16(const char *pszFormat, ...) 394 396 { 395 397 int cch; … … 413 415 static void choutconsole(int ch) 414 416 { 415 USHORT usWrote;416 417 417 if (ch != '\r') 418 418 { 419 USHORT usWrote; /* Bytes written (ignored). */ 419 420 if (ch == '\n') 420 { 421 usWrote = 1; 422 DosWrite(1, (PVOID)&chReturn, 1, &usWrote); 423 } 424 usWrote = 1; 425 DosWrite(1, (PVOID)&ch, 1, &usWrote); 421 DosWrite(1, (PVOID)&chReturnWithNewLine, 2, &usWrote); 422 else 423 DosWrite(1, (PVOID)&ch, 1, &usWrote); 426 424 } 427 425 } … … 438 436 * At runtime the text is only sendt to com-port. 439 437 */ 440 static char *stroutconsole(char *psz, signed cchMax) 441 { 438 static char *stroutconsole(register char *psz, signed cchMax) 439 { 440 register CHAR ch; 441 442 442 while (cchMax > 0 && *psz != '\0') 443 443 { 444 USHORTcch = 0;445 USHORT us;446 447 while (cchMax - cch > 0 && psz[cch] != '\0' && psz[cch] != '\r' && psz[cch]!= '\n')444 register signed cch = 0; 445 USHORT us; /* Bytes written (ignored). */ 446 447 while (cchMax > cch && (ch = psz[cch]) != '\0' && ch != '\r' && ch != '\n') 448 448 cch++; 449 449 450 450 /* write string part */ 451 us = cch;452 451 DosWrite(1, (PVOID)psz, cch, &us); 453 452 454 /* cr and lf check + skip */ 455 if (psz[cch] == '\n' || psz[cch] == '\r') 456 { 457 if (psz[cch] == '\n') 458 { 459 DosWrite(1, (PVOID)&chReturn, 1, &us); 460 DosWrite(1, (PVOID)&chNewLine, 1, &us); 461 } 462 463 while (cchMax - cch > 0 && (psz[cch] == '\r' || psz[cch] == '\n')) 464 cch++; 453 /* cr and lf: expand lf to cr+lf and ignore cr. */ 454 while (cchMax > cch) 455 { 456 if ((ch = psz[cch]) == '\n') 457 DosWrite(1, (PVOID)&chReturnWithNewLine, 2, &us); 458 else 459 if (ch != '\r') 460 break; 461 cch++; 465 462 } 466 463 … … 481 478 static void chout(int ch) 482 479 { 483 #if def RING0480 #if defined(RING0) && !defined(R3TST) 484 481 if (fInitTime) 485 482 choutconsole(ch); … … 514 511 static char *strout(char *psz, signed cchMax) 515 512 { 516 #if def RING0513 #if defined(RING0) && !defined(R3TST) 517 514 int cchYield = 0; 518 515 … … 539 536 540 537 /* cr and lf check + skip */ 541 if ( psz[cch] == '\n' || psz[cch] == '\r')538 if (cch < cchMax && (psz[cch] == '\n' || psz[cch] == '\r')) 542 539 { 543 540 if (psz[cch] == '\n')
Note:
See TracChangeset
for help on using the changeset viewer.
