File: backslash_in.awk

package info (click to toggle)
runawk 1.6.1-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 712 kB
  • sloc: awk: 1,127; ansic: 736; sh: 420; makefile: 103
file content (39 lines) | stat: -rw-r--r-- 812 bytes parent folder | download | duplicates (4)
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
# Written by Aleksey Cheusov <vle@gmx.net>, public domain
#
# This awk module is a part of RunAWK distribution,
#        http://sourceforge.net/projects/runawk
#
############################################################

# =head2 backslash_in.awk
#
# As the name of this module (_in suffix) says this module
# reads and optionally changes input lines.
# 
# Backslash character at the end of line is treated as a sign
# that current line is continued on the next one.
# Example is below.
#
# Input:
#     a b c\
#     d e f g
#     a
#     b
#     e\
#       f
#
# What your program using backslash_in.awk will obtain:
#     a b cd e f g
#     a
#     b
#     e  f
#

#use "xgetline.awk"

{
	while ($0 ~ /\\/){
		assert(xgetline() > 0, "unexpected end of file")
		$0 = substr($0, 1, length($0)-1) __input
	}
}