| 1293 |
dpurdie |
1 |
###############################################################################
|
|
|
2 |
# Codestriker: Copyright (c) 2001, 2002, 2003 David Sitsky.
|
|
|
3 |
# All rights reserved.
|
|
|
4 |
# sits@users.sourceforge.net
|
|
|
5 |
#
|
|
|
6 |
# This program is free software; you can redistribute it and modify it under
|
|
|
7 |
# the terms of the GPL.
|
|
|
8 |
|
|
|
9 |
# Parser object used when a text file is in an unknown format. Treat it as a
|
|
|
10 |
# single new file with name "unknown".
|
|
|
11 |
|
|
|
12 |
package Codestriker::FileParser::UnknownFormat;
|
|
|
13 |
|
|
|
14 |
use strict;
|
|
|
15 |
|
|
|
16 |
# Return the array of filenames, revision number, linenumber, whether its
|
|
|
17 |
# binary or not, and the diff text.
|
|
|
18 |
sub parse ($$) {
|
|
|
19 |
my ($type, $fh, $uploaded_filename) = @_;
|
|
|
20 |
|
|
|
21 |
# Array of results found.
|
|
|
22 |
my @result = ();
|
|
|
23 |
|
|
|
24 |
# Read in all of the data as a single chunk.
|
|
|
25 |
my $text = "";
|
|
|
26 |
while (defined(my $line = <$fh>)) {
|
|
|
27 |
$text .= "+$line";
|
|
|
28 |
}
|
|
|
29 |
|
|
|
30 |
my $chunk = {};
|
|
|
31 |
|
|
|
32 |
$chunk->{filename} = $uploaded_filename;
|
|
|
33 |
$chunk->{revision} = $Codestriker::ADDED_REVISION;
|
|
|
34 |
$chunk->{old_linenumber} = 0;
|
|
|
35 |
$chunk->{new_linenumber} = 1;
|
|
|
36 |
$chunk->{binary} = 0;
|
|
|
37 |
$chunk->{text} = $text;
|
|
|
38 |
$chunk->{description} = "";
|
|
|
39 |
$chunk->{repmatch} = 0;
|
|
|
40 |
push @result, $chunk;
|
|
|
41 |
|
|
|
42 |
return @result;
|
|
|
43 |
}
|
|
|
44 |
|
|
|
45 |
1;
|