monotone

monotone Mtn Source Tree

Root/contrib/get_stdio.pl

  • Property mtn:execute set to true
1#!/usr/bin/perl
2#Timothy Brownawell
3
4#get_stdio.pl filename n
5#Get the output from command n as one piece
6#filename holds the output from "monotone automate stdio"
7
8$x="";
9open $file, $ARGV[0];
10while(<$file>)
11{
12$x = $x . $_;
13}
14
15# packet is cmdnum:errcode:(last|more):size:contents
16# note that contents may contain newlines (or may even be binary)
17# this does:
18
19# for i in split_into_packets($x)
20# $results[i.cmdnum] += i.contents
21#
22# print $results[n]
23
24# read a packet from $x (the contents of the file)
25while($x =~ /(\d+)\:\d+\:[lm]\:(\d+)\:/s)
26{# $1, $2, etc (what was matched by the parentheses) are dynamically scoped
27$m=int($2);
28my $n="";
29$x = $'; #' # what's left after the end of the match
30for(;$m > 0; $m--) # read $m bytes, leaving $x as what's left
31{
32$x =~ /(.)/s;
33$n = $n . $1;
34$x = $'; #' # gedit syntax coloring gets messed up on $' .
35}
36$results[$1] = $results[$1] . $n; # the $1 from the while
37}
38print $results[$ARGV[1]];

Archive Download this file

Branches

Tags

Quick Links:     www.monotone.ca    -     Downloads    -     Documentation    -     Wiki    -     Code Forge    -     Build Status