~csurbhi/ubuntu/maverick/e2fsprogs/e2fsprogs.fix-505719

« back to all changes in this revision

Viewing changes to lib/et/com_err.c

  • Committer: Bazaar Package Importer
  • Author(s): Scott James Remnant
  • Date: 2010-06-07 15:49:29 UTC
  • mfrom: (8.2.4 sid)
  • Revision ID: james.westby@ubuntu.com-20100607154929-grzivujb4fs2nvb3
Tags: 1.41.12-1ubuntu1
* Merge from Debian unstable, remaining changes:
  - Do not build-depend on dietlibc-dev, which is universe.
  - Do now allow pkg-create-dbgsym to operate on this package.
  - Always use external libblkid and libuuid from util-linux, rather than
    building our own.
  - Includes debian/control in the source package to force the above.
  - Build with -O2 on powerpc to avoid a suspected toolchain bug
    (LP: #450214).
  - Do not include /etc/e2fsck.conf and remove on upgrade.
  (Fixes LP: #521648, #537483, #530071)

Show diffs side-by-side

added added

removed removed

Lines of Context:
12
12
 */
13
13
 
14
14
#include <stdio.h>
 
15
#ifdef HAVE_TERMIOS_H
 
16
#include <termios.h>
 
17
#endif
 
18
#ifdef HAVE_UNISTD_H
 
19
#include <unistd.h>
 
20
#endif
15
21
#include "com_err.h"
16
22
#include "error_table.h"
17
23
#include "internal.h"
25
31
default_com_err_proc (const char *whoami, errcode_t code, const
26
32
                      char *fmt, va_list args)
27
33
{
 
34
    int do_cr = 1, fd = fileno(stderr);
 
35
 
28
36
    if (whoami) {
29
37
        fputs(whoami, stderr);
30
38
        fputs(": ", stderr);
36
44
    if (fmt) {
37
45
        vfprintf (stderr, fmt, args);
38
46
    }
39
 
    /* should output \r only if using a tty in raw mode */
40
 
    fputs("\r\n", stderr);
 
47
    if (!isatty(fd))
 
48
        do_cr = 0;
 
49
#ifdef HAVE_TERMIOS_H
 
50
    else {
 
51
        struct termios t;
 
52
 
 
53
        if ((tcgetattr(fd, &t)) == 0 &&
 
54
            (t.c_oflag & OPOST) && (t.c_oflag & ONLCR))
 
55
        do_cr = 0;
 
56
    }
 
57
#endif
 
58
    if (do_cr)
 
59
        fputc('\r', stderr);
 
60
    fputc('\n', stderr);
41
61
    fflush(stderr);
42
62
}
43
63