File: unbackslsh.awk

package info (click to toggle)
tetex-bin 1.0.7%2B20011202-7.3
  • links: PTS
  • area: main
  • in suites: woody
  • size: 45,604 kB
  • ctags: 32,286
  • sloc: ansic: 254,806; cpp: 195,997; sh: 17,818; perl: 9,319; makefile: 3,461; yacc: 1,918; pascal: 1,328; awk: 986; asm: 851; lex: 813; sed: 511; lisp: 276; csh: 47
file content (46 lines) | stat: -rwxr-xr-x 915 bytes parent folder | download | duplicates (19)
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
#! /usr/bin/awk -f
# The relevant lines look like `  \'.
/^ *\\$/{
	  if (!backslashed)
	    {
	      #print "not backslashed -- setting to empty backslash";
	      backslashed = $0;
	    }
	  next;
	}
/\\$/	{
          if (backslashed)
            {
              #print "already backslashed";
              print backslashed;
            }
            
          backslashed = $0;
          #print "setting bs to " backslashed;
          next;
        }

/^ *$/	{ 
          if (backslashed)
	    {
	      #print "spaces only -- prev was backslashed";
	      print substr (backslashed, 1, length (backslashed) - 1);
  	      backslashed = "";
	    }
	  else
	    {
	      #print "spaces only -- prev not backslashed";
	      print;
	    }
	  next;
	}

	{ 
          if (backslashed)
	    {
	      #print "normal line -- prev backslashed";
  	      print backslashed;
  	      backslashed = "";
	    }
	  print
	}