File: overflow.cc

package info (click to toggle)
bobcat 1.11.0-1
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 3,344 kB
  • ctags: 473
  • sloc: makefile: 12,078; cpp: 5,121; ansic: 63; sh: 14
file content (36 lines) | stat: -rw-r--r-- 959 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#include "logbuffer.ih"

int LogBuffer::overflow(int c)
{
    if (!d_active)          // ignore the char if we're not active.
        return c;

    if (c == 0)             // newline without timestamp request
        d_empty = false;

    if (d_insertTimestamp)  // timestamps requested
    {
        if (d_empty)        // write one if there's nothing on the line
        {
            insertTimestamp();
            d_empty = false;
        }
    }
    switch (c)
    {
        case 0:             // write newline, without considering d_empty true
            c = '\n';       // also see logbuffer/operatorinsert.cc
        break;

        case '\n':          // at '\n', set d_empty to true. This generates 
                            // a timestamp at the next insertion
            d_empty = true;
        break;
    }

    return 
        d_stream->write(reinterpret_cast<char const *>(&c), sizeof(char)) ?
            c
        :
            EOF;
}