summaryrefslogtreecommitdiff
path: root/sysutils/guitar/scripts
diff options
context:
space:
mode:
authorSteve Price <steve@FreeBSD.org>1999-11-01 03:09:23 +0000
committerSteve Price <steve@FreeBSD.org>1999-11-01 03:09:23 +0000
commit9d286945bf36fe40911fbdf6f47769794e77e825 (patch)
tree9749f2caeed66ce69befb6c85dee7c12d21d04cd /sysutils/guitar/scripts
parentInitial import of gpart version 0.1e. (diff)
Initial import of guiTAR version 0.1.4.
A gtk+/GNOME frontend to tar, gzip, bzip2, slp, rar, lha, arj, and zip. PR: 13136 Submitted by: Dominik Brettnacher <domi@saargate.de>
Notes
Notes: svn path=/head/; revision=22801
Diffstat (limited to 'sysutils/guitar/scripts')
-rw-r--r--sysutils/guitar/scripts/bsdtar2gnutar44
1 files changed, 44 insertions, 0 deletions
diff --git a/sysutils/guitar/scripts/bsdtar2gnutar b/sysutils/guitar/scripts/bsdtar2gnutar
new file mode 100644
index 000000000000..cceb658c4790
--- /dev/null
+++ b/sysutils/guitar/scripts/bsdtar2gnutar
@@ -0,0 +1,44 @@
+#!/usr/bin/perl
+# converts output of BSD tar(1) into GNU tar compatible format
+# tries to support localization
+# bug reports are welcome!
+
+# Version 0.01 26.07.1999 Dominik Brettnacher <domi@saargate.de>
+
+# we need POSIX::strftime to find out the national abbreviations for
+# month names (used by BSD tar)
+use POSIX qw(strftime);
+for(0..11)
+{
+ $Month{POSIX::strftime("%b", 0, 0, 0, 1, $_, 0)} = $_ + 1;
+}
+
+while(<>)
+{
+ m/^(.*) (.{6}) ([0-9 ]{2}:\d{2}) (\d{4}) (.*)/ || die "regular expression did not match, please report";
+
+ ($day,$month) = month_or_mday_first($2);
+
+ printf("%s %i-%02i-%02i %s %s\n",$1,$4,$Month{$month},$day,$3,$5);
+}
+
+# BSD tar uses a quite "different" way to output the date, roughly:
+# $date = strftime("%c", ...);
+# $date = substr($date,4,12) . " " . substr($date,20,4);
+# as it uses localization, we must try to find out whether mday is printed
+# before or after the month name itself. this seems to be a solution:
+sub month_or_mday_first
+{
+ if($_[0] =~ m/([0-9 ]{2}) (.{3})/)
+ {
+ return ($1, $2);
+ }
+ elsif($_[0] =~ m/(.{3}) ([0-9 ]{2})/)
+ {
+ return ($2, $1);
+ }
+ else
+ {
+ die "invalid date format $_[0]";
+ }
+}