Author: jajcus
Date: Fri Dec 14 12:52:20 2012
New Revision: 12606

Modified:
   nagios-notify/trunk/nagios-notify
Log:
$(unescape:...) function added

to un-escape newlines in $LONGSERVICEOUTPUT$


Modified: nagios-notify/trunk/nagios-notify
==============================================================================
--- nagios-notify/trunk/nagios-notify   (original)
+++ nagios-notify/trunk/nagios-notify   Fri Dec 14 12:52:20 2012
@@ -82,6 +82,13 @@
                return s;
        }
 
+       # convert "\n", "\t" to the actual control characters
+       function unescape(s) {
+               gsub("\\\\n", "\n", s);
+               gsub("\\\\t", "\t", s);
+               return s;
+       }
+
        # remove quotation marks or regexps if surrounded at both ends
        function unquote(s,   c1, c2) {
                c1 = substr(s, 1, 1);
@@ -277,6 +284,14 @@
                        right = substr($0, RSTART + RLENGTH);
                        $0 = left urlencode(data) right;
                }
+               # $(unescape:data)
+               while (match($0, /\$\(unescape:([^)]*)\)/)) {
+                       pos = length("$(unescape:")
+                       data = substr($0, RSTART + pos, RLENGTH - pos - 1);
+                       left = substr($0, 0, RSTART);
+                       right = substr($0, RSTART + RLENGTH);
+                       $0 = left unescape(data) right;
+               }
 
                # $(math:expression)
                while (match($0, "\$\(math:("MATH_EXPR") *("MATH_OPS") 
*("MATH_EXPR")\)")) {
_______________________________________________
pld-cvs-commit mailing list
[email protected]
http://lists.pld-linux.org/mailman/listinfo/pld-cvs-commit

Reply via email to