summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorDaniel Friesel <derf@derf.homelinux.org>2009-01-02 14:57:11 +0100
committerDaniel Friesel <derf@derf.homelinux.org>2009-01-02 14:57:11 +0100
commit462b6e74a7569208410985d182f1776ff564a89f (patch)
treecc79595894741e6820202e187638dac52c396862 /bin
parent88d4543aa94ed0d51b64a7b94bead73bdd03e3c4 (diff)
tibtoa: Added support for variables (.8Xn)
Diffstat (limited to 'bin')
-rwxr-xr-xbin/tibtoa26
1 files changed, 20 insertions, 6 deletions
diff --git a/bin/tibtoa b/bin/tibtoa
index b4b3290..b66cb46 100755
--- a/bin/tibtoa
+++ b/bin/tibtoa
@@ -638,6 +638,7 @@ sub print_header {
sub header_type($) {
my $header = shift;
given (ord(substr($header, 0x3b, 1))) {
+ when(0x00) { return('var') }
when(0x01) { return('list') }
when(0x02) { return('matrix') }
when(0x05) { return('program') }
@@ -649,6 +650,7 @@ sub header_name($) {
my $header = shift;
my $name;
given (header_type($header)) {
+ when('var') { $name = substr($header, 0x3c, 1) }
when('matrix') { $name = substr($header, 61, 1) }
when('program') {
$name = substr($header, 60, 10);
@@ -689,6 +691,11 @@ sub header_datestr($) {
return(substr(shift, 29, 19));
}
+#sub char_to_digits($) {
+# my $char = shift;
+# return($char >> 4, $char & 0x0f);
+#}
+
getopts('ih', \%opts);
open(PRGM, '<', shift) or die;
@@ -762,9 +769,16 @@ if ($header{type} eq 'program') {
}
}
print "$cache\n";
-} elsif ($header{type} eq 'matrix' or $header{type} eq 'list') {
- my ($step, $exp, $digit);
+} elsif ($header{type} eq 'matrix' or $header{type} eq 'list' or $header{type} eq 'var') {
+ my ($exp, $digit);
my $i = 0;
+
+ if ($header{type} eq 'var') {
+ # Variables have a shorter header
+ substr($program, 0, 0, substr($header, -2, 2));
+ $length = length($program);
+ }
+
while ($offset+9 <= $length) {
$i++;
$digit = '';
@@ -772,14 +786,12 @@ if ($header{type} eq 'program') {
for(1 .. 7) {
$char = ord(substr($program, ++$offset, 1));
$digit .= $char >> 4;
- if ($_ == 1) {
- $digit .= '.';
- }
$digit .= $char & 0x0f;
}
$offset++;
+ substr($digit, 1, 0, '.');
printf('%-8s', $digit * (10 ** $exp));
- if ($header{type} eq 'matrix' and $i == $header{size}->{cols}) {
+ if ($header{type} eq 'matrix' and $i == $header{size}->{cols} or $header{type} eq 'var') {
print "\n";
$i = 0;
} elsif ($header{type} eq 'matrix') {
@@ -819,6 +831,8 @@ Currently, the following file types are supported:
=item * B<*.8Xl> - list files
+=item * B<*.8Xn> - variable files
+
=back
=head1 OPTIONS