2006-09-21 [wwp] 2.4.0cvs204
authorTristan Chabredier <wwp@claws-mail.org>
Thu, 21 Sep 2006 08:15:45 +0000 (08:15 +0000)
committerTristan Chabredier <wwp@claws-mail.org>
Thu, 21 Sep 2006 08:15:45 +0000 (08:15 +0000)
* tools/fix_date.sh
* tools/Makefile.am
Added an action tool to fix missing Date field in emails.
Updated Makefile.am to reflect those last two additions.

ChangeLog
PATCHSETS
configure.ac
tools/Makefile.am
tools/fix_date.sh [new file with mode: 0644]

index 9c71880..d480f87 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2006-09-21 [wwp]       2.4.0cvs204
+
+       * tools/fix_date.sh
+       * tools/Makefile.am
+               Added an action tool to fix missing Date field in emails.
+               Updated Makefile.am to reflect those last two additions.
+
 2006-09-21 [wwp]       2.4.0cvs203
 
        * tools/uuooffice
index ece5d75..39c247a 100644 (file)
--- a/PATCHSETS
+++ b/PATCHSETS
 ( cvs diff -u -r 1.382.2.308 -r 1.382.2.309 src/compose.c;  ) > 2.4.0cvs201.patchset
 ( cvs diff -u -r 1.382.2.309 -r 1.382.2.310 src/compose.c;  cvs diff -u -r 1.96.2.148 -r 1.96.2.149 src/textview.c;  ) > 2.4.0cvs202.patchset
 ( diff -u /dev/null tools/uuooffice;  ) > 2.4.0cvs203.patchset
+( diff -u /dev/null tools/fix_date.sh;  cvs diff -u -r 1.25.2.10 -r 1.25.2.11 tools/Makefile.am;  ) > 2.4.0cvs204.patchset
index 3866eca..3b6e448 100644 (file)
@@ -11,7 +11,7 @@ MINOR_VERSION=4
 MICRO_VERSION=0
 INTERFACE_AGE=0
 BINARY_AGE=0
-EXTRA_VERSION=203
+EXTRA_VERSION=204
 EXTRA_RELEASE=
 EXTRA_GTK2_VERSION=
 
index 957a453..7f1a2dc 100644 (file)
@@ -4,6 +4,7 @@ EXTRA_TOOLS = \
        calypso_convert.pl \
        convert_mbox.pl \
        eud2gc.py \
+       fix_date.sh \
        filter_conv.pl \
        filter_conv_new.pl \
        freshmeat_search.pl \
@@ -24,6 +25,7 @@ EXTRA_TOOLS = \
        textviewer.sh \
         update-po \
        uudec \
+       uuooffice \
        vcard2xml.py \
        kdeservicemenu/install.sh \
        kdeservicemenu/sylpheed-kdeservicemenu.pl
diff --git a/tools/fix_date.sh b/tools/fix_date.sh
new file mode 100644 (file)
index 0000000..1271841
--- /dev/null
@@ -0,0 +1,71 @@
+#!/bin/sh
+
+# usage: fix_date.sh <filename> [<filename>..]
+# It will replace the Date: value w/ the one picked up from more recent
+# Received: field if this field resides in one line. Otherwise, it will
+# take the file modification time (using a RFC 2822-compliant form).
+# If no X-Original-Date already exist, the former Date value will be set
+# in such field.
+
+if [ $# -lt 1 ]
+then
+       echo "usage: ${0##*/} <filename> [<filename> ..]"
+       exit 1
+fi
+
+TMP="/tmp/${0##*/}.tmp"
+while [ -n "$1" ]
+do
+       test ! -s "$1" && \
+               continue
+
+       X_ORIGINAL_DATE=$(grep -Eim 1 '^X-Original-Date: ' "$1" | cut -d ':' -f 2)
+       DATE=$(grep -Eim 1 '^Date: ' "$1" | cut -d ':' -f 2)
+       RECEIVED_DATE=$(grep -Eim 1 ';( (Mon|Tue|Wed|Thu|Fri|Sat|Sun),)? [0-9]+ (Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dev) [0-9]+ [0-9]+:[0-9]+:[0-9}+ [-+][0-9]+' "$1" | cut -d ';' -f 2)
+# strict, day of week needed
+#      RECEIVED_DATE=$(grep -Eim 1 '; (Mon|Tue|Wed|Thu|Fri|Sat|Sun), [0-9]+ (Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dev) [0-9]+ [0-9]+:[0-9]+:[0-9}+ [-+][0-9]+' "$1" | cut -d ';' -f 2)
+       FILE_DATE=$(ls -l --time-style="+%a, %d %b %Y %X %z" "$1" | tr -s ' ' ' ' | cut -d ' ' -f 6-11)
+       # we could also use the system date as a possible replacement
+       #SYSTEM_DATE="$(date -R)"
+
+       # determine which replacement date to use
+       if [ -z "$RECEIVED_DATE" ]
+       then
+               # don't forget to add the leading whitespace
+               REPLACEMENT_DATE=" $FILE_DATE"
+       else
+               REPLACEMENT_DATE="$RECEIVED_DATE"
+       fi
+
+       # ensure that a X-Original-Date is set
+       if [ -z "$X_ORIGINAL_DATE" ]
+       then
+               test -z "$DATE" && \
+                       echo "X-Original-Date:$REPLACEMENT_DATE" > "$TMP" || \
+                       echo "X-Original-Date:$DATE" > "$TMP"
+       else
+               :> "$TMP"
+       fi
+
+       # replace/set the date and write all lines
+       if [ -z "$DATE" ]
+       then
+               echo "Date:$REPLACEMENT_DATE" >> "$TMP"
+               cat "$1" >> "$TMP"
+       else
+               sed "s/^Date: .*/Date:$REPLACEMENT_DATE/" "$1" >> "$TMP"
+       fi
+
+       # uncomment the following line to backup the original file
+       #mv -f "$1" "$1.bak"
+
+       mv -f "$TMP" "$1"
+       if [ $? -ne 0 ]
+       then
+               echo "error while moving $TMP to $1"
+               exit 1
+       fi
+
+       shift
+done
+exit 0