~ubuntu-branches/ubuntu/raring/kdebase/raring

« back to all changes in this revision

Viewing changes to konsole/tests/quote.c

  • Committer: Bazaar Package Importer
  • Author(s): Philip Muškovac, Jonathan Riddell, Felix Geyer
  • Date: 2011-03-03 16:25:47 UTC
  • mfrom: (1.1.58 upstream)
  • Revision ID: james.westby@ubuntu.com-20110303162547-2zf9j33cu6j5gj0a
Tags: 4:4.6.1a-0ubuntu1
[ Jonathan Riddell ]
* New upstream release
* Update kde-sc-dev-latest version

[ Felix Geyer ]
* Reduce the x-www-browser priority for konqueror to 30 as rekonq is the
  default Kubuntu browser.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// a silly quotation utitility
 
2
 
 
3
/*
 
4
   This code was written by Lars Doelle <lars.doelle@on-line.de>.
 
5
   This code is in the public domain.
 
6
*/
 
7
 
 
8
#include <stdio.h>
 
9
#include <strings.h>
 
10
 
 
11
int skip = 0;
 
12
int empty = 1;
 
13
 
 
14
void pchr(int c, int indent)
 
15
{
 
16
  if (skip)
 
17
  {
 
18
    skip = (c != '\n');
 
19
    return;
 
20
  }
 
21
  switch(c)
 
22
  {
 
23
    case '\n':
 
24
       if (!empty)
 
25
           printf("\\n\"\n%*s\"",indent,"");
 
26
       empty = 1;
 
27
       break;
 
28
    case '#' :
 
29
       skip = 1;
 
30
       break;
 
31
    case '"' : case '\\': 
 
32
       printf("\\");
 
33
       // fallthrough
 
34
    default:
 
35
       printf("%c",c);
 
36
       empty = 0;
 
37
       break;
 
38
  }
 
39
}
 
40
 
 
41
#define INDENT 2
 
42
 
 
43
int main(int argc, char* argv[])
 
44
{ int cc; FILE *sysin;
 
45
  if (argc < 2) { fprintf(stderr,"usage: %s filename\n",argv[0]); return 1; }
 
46
  sysin = fopen(argv[1],"r");
 
47
  if (!sysin) { fprintf(stderr,"cannot open %s\n",argv[1]); perror("reason: "); return 1; }
 
48
  printf("%*s/* generated by '%s %s' */\n\n",INDENT,"",argv[0],argv[1]);
 
49
  printf("%*s\"",INDENT,"");
 
50
  while( (cc = fgetc(sysin)) > 0)
 
51
  {
 
52
    pchr(cc,INDENT);
 
53
  }
 
54
  printf("\"\n");
 
55
}