~ubuntu-branches/ubuntu/utopic/coreutils/utopic-proposed

« back to all changes in this revision

Viewing changes to src/cat.c

  • Committer: Package Import Robot
  • Author(s): Colin Watson
  • Date: 2012-11-28 03:03:42 UTC
  • mfrom: (8.3.4 sid)
  • Revision ID: package-import@ubuntu.com-20121128030342-21zanj8354gas5gr
Tags: 8.20-3ubuntu1
* Resynchronise with Debian.  Remaining changes:
  - Make 'uname -i -p' return the real processor/hardware, instead of
    unknown.
  - Build-depend on gettext:any instead of on gettext, so that apt-get can
    properly resolve build-dependencies on the tool when cross-building.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* cat -- concatenate files and print on the standard output.
2
 
   Copyright (C) 1988, 1990-1991, 1995-2011 Free Software Foundation, Inc.
 
2
   Copyright (C) 1988-2012 Free Software Foundation, Inc.
3
3
 
4
4
   This program is free software: you can redistribute it and/or modify
5
5
   it under the terms of the GNU General Public License as published by
41
41
#include "safe-read.h"
42
42
#include "xfreopen.h"
43
43
 
44
 
/* The official name of this program (e.g., no `g' prefix).  */
 
44
/* The official name of this program (e.g., no 'g' prefix).  */
45
45
#define PROGRAM_NAME "cat"
46
46
 
47
47
#define AUTHORS \
65
65
    '\t', '\0'
66
66
  };
67
67
 
68
 
/* Position in `line_buf' where printing starts.  This will not change
 
68
/* Position in 'line_buf' where printing starts.  This will not change
69
69
   unless the number of lines is larger than 999999.  */
70
70
static char *line_num_print = line_buf + LINE_COUNTER_BUF_LEN - 8;
71
71
 
72
 
/* Position of the first digit in `line_buf'.  */
 
72
/* Position of the first digit in 'line_buf'.  */
73
73
static char *line_num_start = line_buf + LINE_COUNTER_BUF_LEN - 3;
74
74
 
75
 
/* Position of the last digit in `line_buf'.  */
 
75
/* Position of the last digit in 'line_buf'.  */
76
76
static char *line_num_end = line_buf + LINE_COUNTER_BUF_LEN - 3;
77
77
 
78
 
/* Preserves the `cat' function's local `newlines' between invocations.  */
 
78
/* Preserves the 'cat' function's local 'newlines' between invocations.  */
79
79
static int newlines2 = 0;
80
80
 
81
81
void
82
82
usage (int status)
83
83
{
84
84
  if (status != EXIT_SUCCESS)
85
 
    fprintf (stderr, _("Try `%s --help' for more information.\n"),
86
 
             program_name);
 
85
    emit_try_help ();
87
86
  else
88
87
    {
89
88
      printf (_("\
145
144
    line_num_print--;
146
145
}
147
146
 
148
 
/* Plain cat.  Copies the file behind `input_desc' to STDOUT_FILENO.
 
147
/* Plain cat.  Copies the file behind 'input_desc' to STDOUT_FILENO.
149
148
   Return true if successful.  */
150
149
 
151
150
static bool
652
651
  else
653
652
    {
654
653
      check_redirection = false;
655
 
#ifdef lint  /* Suppress `used before initialized' warning.  */
 
654
#ifdef lint  /* Suppress 'used before initialized' warning.  */
656
655
      out_dev = 0;
657
656
      out_ino = 0;
658
657
#endif
719
718
          goto contin;
720
719
        }
721
720
 
722
 
      /* Select which version of `cat' to use.  If any format-oriented
723
 
         options were given use `cat'; otherwise use `simple_cat'.  */
 
721
      /* Select which version of 'cat' to use.  If any format-oriented
 
722
         options were given use 'cat'; otherwise use 'simple_cat'.  */
724
723
 
725
724
      if (! (number || show_ends || show_nonprinting
726
725
             || show_tabs || squeeze_blank))
752
751
             A line number requires seldom more than LINE_COUNTER_BUF_LEN
753
752
             positions.
754
753
 
755
 
             Align the output buffer to a page size boundary, for efficency on
756
 
             some paging implementations, so add PAGE_SIZE - 1 bytes to the
 
754
             Align the output buffer to a page size boundary, for efficiency
 
755
             on some paging implementations, so add PAGE_SIZE - 1 bytes to the
757
756
             request to make room for the alignment.  */
758
757
 
759
758
          outbuf = xmalloc (outsize - 1 + insize * 4 + LINE_COUNTER_BUF_LEN