~ubuntu-branches/ubuntu/precise/gnupg2/precise-proposed

« back to all changes in this revision

Viewing changes to tools/crlf.c

  • Committer: Bazaar Package Importer
  • Author(s): Matthias Urlichs
  • Date: 2006-01-24 04:31:42 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20060124043142-pbg192or6qxv3yk2
Tags: 1.9.20-1
* New Upstream version. Closes:#306890,#344530
  * Closes:#320490: gpg-protect-tool fails to decrypt PKCS-12 files 
* Depend on libopensc2-dev, not -1-. Closes:#348106

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* crlf.c
 
2
 * Copyright (C) 1999, 2000, 2001 Free Software Foundation, Inc.
 
3
 *
 
4
 * This file is free software; as a special exception the author gives
 
5
 * unlimited permission to copy and/or distribute it, with or without
 
6
 * modifications, as long as this notice is preserved.
 
7
 *
 
8
 * This program is distributed in the hope that it will be useful, but
 
9
 * WITHOUT ANY WARRANTY, to the extent permitted by law; without even the
 
10
 * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 
11
 */
 
12
 
 
13
#include <stdio.h>
 
14
 
 
15
int
 
16
main(int argc, char **argv)
 
17
{
 
18
    int c, lc;
 
19
    int off=0;
 
20
 
 
21
    if( argc > 1 ) {
 
22
        fprintf(stderr, "no arguments, please\n");
 
23
        return 1;
 
24
    }
 
25
 
 
26
    lc = -1;
 
27
    while( (c=getchar()) != EOF ) {
 
28
      #if 0
 
29
        if( c == '\r' && lc == ' ' )
 
30
            fprintf(stderr,"SP,CR at %d\n", off );
 
31
        if( c == '\n' && lc == ' ' )
 
32
            fprintf(stderr,"SP,LF at %d\n", off );
 
33
      #endif
 
34
        if( c == '\n' && lc == '\r' )
 
35
            putchar(c);
 
36
        else if( c == '\n' ) {
 
37
            putchar('\r');
 
38
            putchar(c);
 
39
        }
 
40
        else if( c != '\n' && lc == '\r' ) {
 
41
            putchar('\n');
 
42
            putchar(c);
 
43
        }
 
44
        else
 
45
            putchar(c);
 
46
 
 
47
        lc = c;
 
48
        off++;
 
49
    }
 
50
 
 
51
    return 0;
 
52
}
 
53