Annotation of researchv10dc/libI77/notused/puts.c, revision 1.1

1.1     ! root        1: /*     @(#)puts.c      3.3     */
        !             2: /*LINTLIBRARY*/
        !             3: /*
        !             4:  * This version writes directly to the buffer rather than looping on putc.
        !             5:  * Ptr args aren't checked for NULL because the program would be a
        !             6:  * catastrophic mess anyway.  Better to abort than just to return NULL.
        !             7:  */
        !             8: #include <stdio.h>
        !             9: #include "stdiom.h"
        !            10: 
        !            11: extern char *memccpy();
        !            12: 
        !            13: int
        !            14: puts(ptr)
        !            15: char *ptr;
        !            16: {
        !            17:        char *p;
        !            18:        register int ndone = 0, n;
        !            19:        register unsigned char *cptr, *bufend;
        !            20: 
        !            21:        if (_WRTCHK(stdout))
        !            22:                return (0);
        !            23: 
        !            24:        bufend = _bufend(stdout);
        !            25: 
        !            26:        for ( ; ; ptr += n) {
        !            27:                while ((n = bufend - (cptr = stdout->_ptr)) <= 0) /* full buf */
        !            28:                        if (_xflsbuf(stdout) == EOF)
        !            29:                                return(EOF);
        !            30:                if ((p = memccpy((char *) cptr, ptr, '\0', n)) != NULL)
        !            31:                        n = p - (char *) cptr;
        !            32:                stdout->_cnt -= n;
        !            33:                stdout->_ptr += n;
        !            34:                _BUFSYNC(stdout);
        !            35:                ndone += n;
        !            36:                if (p != NULL) {
        !            37:                        stdout->_ptr[-1] = '\n'; /* overwrite '\0' with '\n' */
        !            38:                        if (stdout->_flag & (_IONBF | _IOLBF)) /* flush line */
        !            39:                                if (_xflsbuf(stdout) == EOF)
        !            40:                                        return(EOF);
        !            41:                        return(ndone);
        !            42:                }
        !            43:        }
        !            44: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.