File: tab2spc.c

package info (click to toggle)
libflux0 0.3.0-5
  • links: PTS
  • area: main
  • in suites: woody
  • size: 2,244 kB
  • ctags: 2,028
  • sloc: ansic: 15,937; sh: 7,704; java: 470; makefile: 126; lex: 108
file content (48 lines) | stat: -rw-r--r-- 1,310 bytes parent folder | download
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
37
38
39
40
41
42
43
44
45
46
47
48
/* Copyright (C) 1999 Hans Petter K. Jansson
 *
 * This library is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this library; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
 *
 * You can contact the library's author by sending e-mail to <hpj@styx.net>.
 */

/* Converts two spaces at line's beginning to one tab, stdin to stdout. */

#include <stdio.h>


int main(int argc, char *argv[])
{
  char buf[4096];
  char *buf_ptr;
  
  for (;;)
  {
    fgets(buf, 4095, stdin);
    if (feof(stdin)) break;
    buf_ptr = buf;

    for (; *buf_ptr; buf_ptr++)
    {
      if (*buf_ptr == 0x09)
      {
        fputc(' ', stdout);
        fputc(' ', stdout);
      }
      else fputc(*buf_ptr, stdout);
    }
  }
  
  return(0);
}