summaryrefslogtreecommitdiff
path: root/Build/source/texk/unbackslsh.awk
blob: ebbd1d0c34c7258a1d1334978fa3d0a1aa828148 (plain)
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
	}