Re: [PATCH] Make imap_free_header_data type-safe

2012-12-14 Thread Vincent Lefevre
On 2012-12-14 14:28:14 +1100, Cameron Simpson wrote:
> On 09Sep2012 20:00, Andrew Gaul  wrote:
> | -  /* suppress GCC aliasing warning */
> | - imap_free_header_data ((void**) (void*) &h.data);
> 
> Pardon my ignorance, but what is (was?) the use of a cast like:
> 
>   (void**) (void*)
> 
> A cast of a typed pointer to (void *) when handing it to something
> generic like free() I understand, but the above confuses me. I don't
> expect C to confuse me.

I suppose that the (void**) was necessary to have the correct type
(this is needed when compiling with a C++ compiler such as g++),
and (void*) to avoid the GCC aliasing warning (but this was really
dangerous, because if there is an aliasing problem, wrong code can
be generated).

In general, casting a pointer type to another pointer type (except
with things like char * and void *) is dangerous, because it may
be the source of aliasing problem. See the ISO C standard for more
details.

-- 
Vincent Lefèvre  - Web: 
100% accessible validated (X)HTML - Blog: 
Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)


Re: [Mutt] #3608: Character Š wrong in index and status on Mac OS X

2012-12-14 Thread Mutt
#3608: Character Š wrong in index and status on Mac OS X
+---
 Reporter:  kolcon  |   Owner:  mutt-dev
 Type:  defect  |  Status:  new 
 Priority:  minor   |   Milestone:  
Component:  mutt| Version:  1.5.21  
 Keywords:  |  
+---

Comment(by vinc17):

 Is this related to bug #2956 (which is about the same character)?

-- 
Ticket URL: 
Mutt 
The Mutt mail user agent



Re: [Mutt] #3608: Character Š wrong in index and status on Mac OS X

2012-12-14 Thread Mutt
#3608: Character Š wrong in index and status on Mac OS X
+---
 Reporter:  kolcon  |   Owner:  mutt-dev
 Type:  defect  |  Status:  new 
 Priority:  minor   |   Milestone:  
Component:  mutt| Version:  1.5.21  
 Keywords:  |  
+---

Comment(by kolcon):

 Replying to [comment:9 vinc17]:
 > Is this related to bug #2956 (which is about the same character)?

 Actually yes, same symptoms here

-- 
Ticket URL: 
Mutt 
The Mutt mail user agent



[PATCH 0 of 3] Regex replacement on Subject

2012-12-14 Thread David Champion
Questions about subject replacement have come up twice recently in
mutt-users, and Michael has expressed support for the principle, so I'm
resending this patch to the -dev list for review.

Patch 1: refactors the regex replacement used by spam matching into a
more abstract replacement mechanism, REPLACE_LIST
Patch 2: adds subject replacement based on the new REPLACE_LIST type
Patch 3: adds mailbox name replacement

Documentation is now included, new since previous patch versions.



[PATCH 1 of 3] Abstract the SPAM_LIST as a generic REPLACE_LIST

2012-12-14 Thread David Champion
# HG changeset patch
# User David Champion 
# Date 1355527735 21600
# Branch HEAD
# Node ID 7a90f541ff6942f05c4ad36130c2354238b1d67d
# Parent  c4c65eadeb7142764bbd73ae63aeef3970669bed
Abstract the SPAM_LIST as a generic REPLACE_LIST

REPLACE_LIST can be used more generally as a list of pattern
match-replace settings.  SPAM_LIST was a special case of this, so
spam handling has been been changed to use REPLACE_LIST instead, and
SPAM_LIST was removed.

A generic function for performing a REPLACE_LIST replacement has
been added in mutt_apply_replace().

diff -r c4c65eadeb71 -r 7a90f541ff69 globals.h
--- a/globals.h Sat Dec 08 12:31:11 2012 +0100
+++ b/globals.h Fri Dec 14 17:28:55 2012 -0600
@@ -168,7 +168,7 @@
 WHERE RX_LIST *UnMailLists INITVAL(0);
 WHERE RX_LIST *SubscribedLists INITVAL(0);
 WHERE RX_LIST *UnSubscribedLists INITVAL(0);
-WHERE SPAM_LIST *SpamList INITVAL(0);
+WHERE REPLACE_LIST *SpamList INITVAL(0);
 WHERE RX_LIST *NoSpamList INITVAL(0);
 
 
diff -r c4c65eadeb71 -r 7a90f541ff69 hcache.c
--- a/hcache.c  Sat Dec 08 12:31:11 2012 +0100
+++ b/hcache.c  Fri Dec 14 17:28:55 2012 -0600
@@ -1125,7 +1125,7 @@
   if (hcachever == 0x0) {
 unsigned char digest[16];
 struct md5_ctx ctx;
-SPAM_LIST *spam;
+REPLACE_LIST *spam;
 RX_LIST *nospam;
 
 hcachever = HCACHEVER;
diff -r c4c65eadeb71 -r 7a90f541ff69 init.c
--- a/init.cSat Dec 08 12:31:11 2012 +0100
+++ b/init.cFri Dec 14 17:28:55 2012 -0600
@@ -451,11 +451,11 @@
   return 0;
 }
 
-static int remove_from_spam_list (SPAM_LIST **list, const char *pat);
-
-static int add_to_spam_list (SPAM_LIST **list, const char *pat, const char 
*templ, BUFFER *err)
+static int remove_from_replace_list (REPLACE_LIST **list, const char *pat);
+
+static int add_to_replace_list (REPLACE_LIST **list, const char *pat, const 
char *templ, BUFFER *err)
 {
-  SPAM_LIST *t = NULL, *last = NULL;
+  REPLACE_LIST *t = NULL, *last = NULL;
   REGEXP *rx;
   int n;
   const char *p;
@@ -488,12 +488,12 @@
   break;
   }
 
-  /* If t is set, it's pointing into an extant SPAM_LIST* that we want to
+  /* If t is set, it's pointing into an extant REPLACE_LIST* that we want to
* update. Otherwise we want to make a new one to link at the list's end.
*/
   if (!t)
   {
-t = mutt_new_spam_list();
+t = mutt_new_replace_list();
 t->rx = rx;
 if (last)
   last->next = t;
@@ -501,7 +501,7 @@
   *list = t;
   }
 
-  /* Now t is the SPAM_LIST* that we want to modify. It is prepared. */
+  /* Now t is the REPLACE_LIST* that we want to modify. It is prepared. */
   t->template = safe_strdup(templ);
 
   /* Find highest match number in template string */
@@ -522,9 +522,9 @@
 
   if (t->nmatch > t->rx->rx->re_nsub)
   {
-snprintf (err->data, err->dsize, _("Not enough subexpressions for spam "
+snprintf (err->data, err->dsize, _("Not enough subexpressions for "
"template"));
-remove_from_spam_list(list, pat);
+remove_from_replace_list(list, pat);
 return -1;
   }
 
@@ -533,38 +533,38 @@
   return 0;
 }
 
-static int remove_from_spam_list (SPAM_LIST **list, const char *pat)
+static int remove_from_replace_list (REPLACE_LIST **list, const char *pat)
 {
-  SPAM_LIST *spam, *prev;
+  REPLACE_LIST *cur, *prev;
   int nremoved = 0;
 
   /* Being first is a special case. */
-  spam = *list;
-  if (!spam)
+  cur = *list;
+  if (!cur)
 return 0;
-  if (spam->rx && !mutt_strcmp(spam->rx->pattern, pat))
+  if (cur->rx && !mutt_strcmp(cur->rx->pattern, pat))
   {
-*list = spam->next;
-mutt_free_regexp(&spam->rx);
-FREE(&spam->template);
-FREE(&spam);
+*list = cur->next;
+mutt_free_regexp(&cur->rx);
+FREE(&cur->template);
+FREE(&cur);
 return 1;
   }
 
-  prev = spam;
-  for (spam = prev->next; spam;)
+  prev = cur;
+  for (cur = prev->next; cur;)
   {
-if (!mutt_strcmp(spam->rx->pattern, pat))
+if (!mutt_strcmp(cur->rx->pattern, pat))
 {
-  prev->next = spam->next;
-  mutt_free_regexp(&spam->rx);
-  FREE(&spam->template);
-  FREE(&spam);
-  spam = prev->next;
+  prev->next = cur->next;
+  mutt_free_regexp(&cur->rx);
+  FREE(&cur->template);
+  FREE(&cur);
+  cur = prev->next;
   ++nremoved;
 }
 else
-  spam = spam->next;
+  cur = cur->next;
   }
 
   return nremoved;
@@ -730,7 +730,7 @@
   mutt_extract_token (&templ, s, 0);
 
   /* Add to the spam list. */
-  if (add_to_spam_list (&SpamList, buf->data, templ.data, err) != 0) {
+  if (add_to_replace_list (&SpamList, buf->data, templ.data, err) != 0) {
  FREE(&templ.data);
   return -1;
   }
@@ -754,13 +754,13 @@
 /* "*" is a special case. */
 if (!mutt_strcmp(buf->data, "*"))
 {
-  mutt_free_spam_list (&SpamList);
+  mutt_free_replace_list (&SpamList);
   mutt_free_rx_list (&NoSpamList);
   return 0;
 }
 
 /* If it's on the spam list, just remove it. */
-

[PATCH 3 of 3] Adds mailboxrx (and unmailboxrx) command

2012-12-14 Thread David Champion
# HG changeset patch
# User David Champion 
# Date 1355527745 21600
# Branch HEAD
# Node ID 8f4ff2c8f2e7314e3d62e879aaf91bb035d92da0
# Parent  ecae1a363182797c2c157e88ff51d07c82f0a20c
Adds mailboxrx (and unmailboxrx) command.

Mailboxrx allows you to define a regular expression and replacement
template for mailbox names.  Wherever status_format's %f is expanded,
the folder name will be matched in turn against each mailboxrx
expression.  If any expression matches, a replacement of the mailbox
name will be performed, with backreference expansion.

Example:
mailboxrx imaps://(.*)@imap.gmail.com/ %1@gmail:%R

This makes any Google Mail IMAP mailbox look like username@gmail:folder.
%1 expands to the first parenthesized subexpression in the regex.  %L is
all text to the left of the matching expression, and %R is all text to
the right of the matching expression.


mailboxrx (pop|imap)s?://.*\.([^.]+).[^.]+/ %2:%R
This more generally simplifies POP or IMAP mailbox display, reducing it
to "domain:folder" where "domain" is the DNS domain of the server minus
the top-level domain (.com, .net, etc).


Mailboxrx commands are stackable.  On top of the above, you could add:
mailboxrx earthlink %Leln%R

This would replace "earthlink" with "eln" regardless of where it appears
in the mailbox name.

diff -r ecae1a363182 -r 8f4ff2c8f2e7 doc/manual.xml.head
--- a/doc/manual.xml.head   Fri Dec 14 17:29:03 2012 -0600
+++ b/doc/manual.xml.head   Fri Dec 14 17:29:05 2012 -0600
@@ -5900,6 +5900,41 @@
 
 
 
+
+Similarly, mailboxrx lets you replace mailbox names in the
+display, which can be useful if they are very long -- for example, mailboxes
+deep in your filesystem, or IMAP URLs with a lot of prefatory junk.
+
+
+
+mailboxrx
+
+pattern
+
+
+replacement
+
+
+unmailboxrx
+
+pattern
+
+
+
+
+Mailbox Munging
+
+# Shorten my home directory path
+mailboxrx '/home/dgc' '~/%R'
+
+# Shorten my Mail folder
+mailboxrx '/home/dgc/[mM]ail/' '=%R'
+
+# Shorten IMAP
+mailboxrx 'imaps?://[^/]*/' 'imap:%R'
+
+
+
 
 
 
diff -r ecae1a363182 -r 8f4ff2c8f2e7 globals.h
--- a/globals.h Fri Dec 14 17:29:03 2012 -0600
+++ b/globals.h Fri Dec 14 17:29:05 2012 -0600
@@ -171,6 +171,7 @@
 WHERE REPLACE_LIST *SpamList INITVAL(0);
 WHERE RX_LIST *NoSpamList INITVAL(0);
 WHERE REPLACE_LIST *SubjectRxList INITVAL(0);
+WHERE REPLACE_LIST *MailboxRxList INITVAL(0);
 
 
 /* bit vector for boolean variables */
diff -r ecae1a363182 -r 8f4ff2c8f2e7 init.h
--- a/init.hFri Dec 14 17:29:03 2012 -0600
+++ b/init.hFri Dec 14 17:29:05 2012 -0600
@@ -3534,6 +3534,8 @@
   { "macro",   mutt_parse_macro,   0 },
   { "mailboxes",   mutt_parse_mailboxes,   M_MAILBOXES },
   { "unmailboxes", mutt_parse_mailboxes,   M_UNMAILBOXES },
+  { "mailboxrx",parse_replace_list, UL &MailboxRxList },
+  { "unmailboxrx",  parse_unreplace_list, UL &MailboxRxList },
   { "message-hook",mutt_parse_hook,M_MESSAGEHOOK },
   { "mbox-hook",   mutt_parse_hook,M_MBOXHOOK },
   { "mime_lookup", parse_list, UL &MimeLookupList },
diff -r ecae1a363182 -r 8f4ff2c8f2e7 muttlib.c
--- a/muttlib.c Fri Dec 14 17:29:03 2012 -0600
+++ b/muttlib.c Fri Dec 14 17:29:05 2012 -0600
@@ -809,10 +809,24 @@
   }
 }
 
+static void apply_mailboxrx (char *s, size_t buflen)
+{
+  char *repl;
+
+  repl = mutt_apply_replace (NULL, 0, s, MailboxRxList);
+  if (repl)
+  {
+strncpy(s, repl, buflen-1);
+s[buflen-1] = '\0';
+FREE(&repl);
+  }
+}
+
 /* collapse the pathname using ~ or = when possible */
-void mutt_pretty_mailbox (char *s, size_t buflen)
+void mutt_pretty_mailbox (char *buf, size_t buflen)
 {
-  char *p = s, *q = s;
+  char *s = buf;
+  char *p = buf, *q = buf;
   size_t len;
   url_scheme_t scheme;
   char tmp[PATH_MAX];
@@ -823,6 +837,7 @@
   if (scheme == U_IMAP || scheme == U_IMAPS)
   {
 imap_pretty_mailbox (s);
+apply_mailboxrx (buf, buflen);
 return;
   }
 #endif
@@ -878,6 +893,8 @@
 *s++ = '~';
 memmove (s, s + len - 1, mutt_strlen (s + len - 1) + 1);
   }
+
+  apply_mailboxrx (buf, buflen);
 }
 
 void mutt_pretty_size (char *s, size_t len, LOFF_T n)



[PATCH 2 of 3] Add subjectrx command to replace matching subjects with something else

2012-12-14 Thread David Champion
# HG changeset patch
# User David Champion 
# Date 1355527743 21600
# Branch HEAD
# Node ID ecae1a363182797c2c157e88ff51d07c82f0a20c
# Parent  7a90f541ff6942f05c4ad36130c2354238b1d67d
Add subjectrx command to replace matching subjects with something else.

This lets you define regular expressions-replacement pairs for subject
display.  When a Subject: matches the regular expression, the replacement
value will be displayed instead in the message index.  Backreferences
are supported.

This is especially nice for simplifying subjects that are overly wordy,
such as mailing list posts (with [Listname] tags, etc), mail from
ticketing systems or bug trackers, etc.  It lets you reduce clutter in
your mutt display without altering the messages themselves.

diff -r 7a90f541ff69 -r ecae1a363182 doc/manual.xml.head
--- a/doc/manual.xml.head   Fri Dec 14 17:28:55 2012 -0600
+++ b/doc/manual.xml.head   Fri Dec 14 17:29:03 2012 -0600
@@ -5836,6 +5836,72 @@
 
 
 
+
+Display Munging
+
+
+Working within the confines of a console or terminal window, it is
+often useful to be able to modify certain information elements in a
+non-destructive way -- to change how they display, without changing
+the stored value of the information itself.  This is especially so of
+message subjects, which may often be polluted with extraneous metadata
+that either is reproduced elsewhere, or is of secondary interest.
+
+
+
+subjectrx
+
+pattern
+
+
+replacement
+
+
+unsubjectrx
+
+pattern
+
+
+
+
+subjectrx specifies a regular expression
+pattern which, if detected in a message subject, causes
+the subject to be replaced with the replacement value.
+The replacement is subject to substitutions in the same way as for the
+spam command: %L for the text
+to the left of the match, %R for text to the right of the
+match, and %1 for the first subgroup in the match (etc).
+If you simply want to erase the match, set it to %L%R.
+Any number of subjectrx commands may coexist.
+
+
+
+Note this well: the replacement value replaces the
+entire subject, not just the match!
+
+
+
+unsubjectrx removes a given subjectrx from the substitution
+list.
+
+
+
+Subject Munging
+
+# Erase [rt #12345] tags from Request Tracker (RT) e-mails
+subjectrx '\[rt #[0-9]+\] *' '%L%R'
+
+# Servicedesk is another RT that sends more complex subjects.
+# Keep the ticket number.
+subjectrx '\[servicedesk #([0-9]+)\] ([^.]+)\.([^.]+) - 
(new|open|pending|update) - ' '%L[#%1] %R'
+
+# Strip out annoying [listname] prefixes in subjects
+subjectrx '\[[^\]]*\]:? *' '%L%R'
+
+
+
+
+
 
 New Mail Detection
 
@@ -9050,6 +9116,23 @@
 
 
 
+subjectrx
+
+pattern
+
+
+format
+
+
+unsubjectrx
+
+pattern
+
+
+
+
+
+
 subscribe
 
 -group
diff -r 7a90f541ff69 -r ecae1a363182 globals.h
--- a/globals.h Fri Dec 14 17:28:55 2012 -0600
+++ b/globals.h Fri Dec 14 17:29:03 2012 -0600
@@ -170,6 +170,7 @@
 WHERE RX_LIST *UnSubscribedLists INITVAL(0);
 WHERE REPLACE_LIST *SpamList INITVAL(0);
 WHERE RX_LIST *NoSpamList INITVAL(0);
+WHERE REPLACE_LIST *SubjectRxList INITVAL(0);
 
 
 /* bit vector for boolean variables */
diff -r 7a90f541ff69 -r ecae1a363182 hdrline.c
--- a/hdrline.c Fri Dec 14 17:28:55 2012 -0600
+++ b/hdrline.c Fri Dec 14 17:29:03 2012 -0600
@@ -199,6 +199,22 @@
   return h->recipient;
 }
 
+static char *apply_subject_mods (ENVELOPE *env)
+{
+  if (env == NULL)
+return NULL;
+
+  if (SubjectRxList == NULL)
+return env->subject;
+
+  if (env->subject == NULL || *env->subject == '\0')
+return env->disp_subj = NULL;
+
+  env->disp_subj = mutt_apply_replace(NULL, 0, env->subject, SubjectRxList);
+  return env->disp_subj;
+}
+
+
 /* %a = address of author
  * %A = reply-to address (if present; otherwise: address of author
  * %b = filename of the originating folder
@@ -549,20 +565,28 @@
   break;
 
 case 's':
-  
-  if (flags & M_FORMAT_TREE && !hdr->collapsed)
   {
-   if (flags & M_FORMAT_FORCESUBJ)
+   char *subj;
+if (hdr->env->disp_subj)
+ subj = hdr->env->disp_subj;
+   else if (SubjectRxList)
+ subj = apply_subject_mods(hdr->env);
+   else
+ subj = hdr->env->subject;
+   if (flags & M_FORMAT_TREE && !hdr->collapsed)
{
- mutt_format_s (dest, destlen, "", NONULL (hdr->env->subject));
- snprintf (buf2, sizeof (buf2), "%s%s", hdr->tree, dest);
- mutt_format_s_tree (dest, destlen, prefix, buf2);
+ if (flags & M_FORMAT_FORCESUBJ)
+ {
+   mutt_format_s (dest, destlen, "", NONULL (subj));
+   snprintf (buf2, sizeof (buf2), "%s%s", hdr->tree, dest);
+   mutt_format_s_tree (dest, destlen, prefix, buf2);
+ }
+ else
+   mutt_format_s_tree (dest, destlen, prefix, hdr->tree);
}
else
- mutt_format_s_tree (dest, destlen, prefix, hdr->tree);
+ mutt_format_s (dest, destlen, prefix, NONULL (subj));
   }
-  else
-   mutt_format_s (dest, destlen, prefix, NONULL (hdr->env->subject));
 

Re: [PATCH 2/4] Generate version string during make not configure

2012-12-14 Thread David Champion
I haven't tested this myself, but in general it looks like a good idea.
Thanks for splitting it into conceptual staged changes -- review is much
easier.

Comments inline as needed.

* On 13 Dec 2012, Aaron Schrab wrote: 
> From: Aaron Schrab 
> 
> Switch to generating the version string during make process rather than
> at configure time.  This makes it easier to keep the detailed version
> string accurate when doing development which doesn't require that the
> configure script be rerun.
> ---
>  .hgignore|1 +
>  Makefile.am  |7 ++-
>  commands.c   |1 +
>  compose.c|1 +
>  configure.ac |3 ---
>  dotlock.c|1 +
>  init.c   |1 +
>  muttlib.c|1 +
>  sendlib.c|1 +
>  status.c |1 +
>  10 files changed, 14 insertions(+), 4 deletions(-)
> 
> diff --git a/.hgignore b/.hgignore
> index 8995db4..6887cc4 100644
> --- a/.hgignore
> +++ b/.hgignore
> @@ -33,6 +33,7 @@
>  ^smime_keys$
>  ^txt2c$
>  ^stamp-doc-rc$
> +^version\.h$
>  ^doc/instdoc$
>  ^doc/manual\.(txt|xml|aux|log|out|tex|pdf)$
>  ^doc/mutt\.1$
> diff --git a/Makefile.am b/Makefile.am
> index 24daaab..284b274 100644
> --- a/Makefile.am
> +++ b/Makefile.am
> @@ -17,7 +17,7 @@ if BUILD_HCACHE
>  HCVERSION = hcversion.h
>  endif
>  
> -BUILT_SOURCES = keymap_defs.h patchlist.c reldate.h conststrings.c 
> $(HCVERSION)
> +BUILT_SOURCES = keymap_defs.h patchlist.c reldate.h conststrings.c version.h 
> $(HCVERSION)
>  
>  bin_PROGRAMS = mutt @DOTLOCK_TARGET@ @PGPAUX_TARGET@
>  mutt_SOURCES = \
> @@ -136,6 +136,11 @@ keymap_alldefs.h: $(srcdir)/OPS $(srcdir)/OPS.PGP 
> $(srcdir)/OPS.MIX $(srcdir)/OP
>   $(srcdir)/OPS.MIX $(srcdir)/OPS.CRYPT $(srcdir)/OPS.SMIME \
>   > keymap_alldefs.h
>  
> +version.h: FORCE
> + echo '#define MUTT_VERSION "'`sh "$(srcdir)/version.sh"`'"' > $@.tmp
> + (cmp -s $@ $@.tmp) && rm -f $@.tmp || mv $@.tmp $@
> +FORCE:
> +

.PHONY: version.h ?

>  reldate.h: $(srcdir)/ChangeLog
>   echo 'const char *ReleaseDate = "'`head -n 1 $(srcdir)/ChangeLog | 
> LC_ALL=C cut -d ' ' -f 1`'";' > reldate.h.tmp; \
>   cmp -s reldate.h.tmp reldate.h || cp reldate.h.tmp reldate.h; \
> diff --git a/commands.c b/commands.c
> index bc1036b..13b12dd 100644
> --- a/commands.c
> +++ b/commands.c
> @@ -21,6 +21,7 @@
>  # include "config.h"
>  #endif
>  
> +#include "version.h"
>  #include "mutt.h"
>  #include "mutt_curses.h"
>  #include "mutt_menu.h"
> diff --git a/compose.c b/compose.c
> index edda021..b641d16 100644
> --- a/compose.c
> +++ b/compose.c
> @@ -21,6 +21,7 @@
>  # include "config.h"
>  #endif
>  
> +#include "version.h"
>  #include "mutt.h"
>  #include "mutt_curses.h"
>  #include "mutt_idna.h"
> diff --git a/configure.ac b/configure.ac
> index 71a6452..ed0bd3d 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -11,9 +11,6 @@ mutt_cv_version=`cat "$srcdir/VERSION"`
>  AM_INIT_AUTOMAKE(mutt, $mutt_cv_version)
>  AC_SUBST([CONFIG_STATUS_DEPENDENCIES], ['$(top_srcdir)/VERSION'])
>  
> -MUTT_VERSION=`env sh "$srcdir/version.sh"`
> -AC_DEFINE_UNQUOTED(MUTT_VERSION,"$MUTT_VERSION", [Full textual version 
> string.])
> -
>  AC_GNU_SOURCE
>  
>  ALL_LINGUAS="de eu ru it es uk fr pl nl cs id sk ko el zh_TW zh_CN pt_BR eo 
> gl sv da lt tr ja hu et ca bg ga"
> diff --git a/dotlock.c b/dotlock.c
> index 5bf0348..9dd958a 100644
> --- a/dotlock.c
> +++ b/dotlock.c
> @@ -46,6 +46,7 @@
>  #include 
>  #endif
>  
> +#include "version.h"
>  #include "dotlock.h"
>  
>  #ifdef HAVE_GETOPT_H
> diff --git a/init.c b/init.c
> index a3ec232..d69fff2 100644
> --- a/init.c
> +++ b/init.c
> @@ -20,6 +20,7 @@
>  # include "config.h"
>  #endif
>  
> +#include "version.h"
>  #include "mutt.h"
>  #include "mapping.h"
>  #include "mutt_curses.h"
> diff --git a/muttlib.c b/muttlib.c
> index 7e93a3a..1f4982b 100644
> --- a/muttlib.c
> +++ b/muttlib.c
> @@ -21,6 +21,7 @@
>  # include "config.h"
>  #endif
>  
> +#include "version.h"
>  #include "mutt.h"
>  #include "mutt_curses.h"
>  #include "mime.h"
> diff --git a/sendlib.c b/sendlib.c
> index 249d6a1..f8d41e1 100644
> --- a/sendlib.c
> +++ b/sendlib.c
> @@ -22,6 +22,7 @@
>  # include "config.h"
>  #endif
>  
> +#include "version.h"
>  #include "mutt.h"
>  #include "mutt_curses.h"
>  #include "rfc2047.h"
> diff --git a/status.c b/status.c
> index 1bb9a5a..acf788e 100644
> --- a/status.c
> +++ b/status.c
> @@ -20,6 +20,7 @@
>  # include "config.h"
>  #endif
>  
> +#include "version.h"
>  #include "mutt.h"
>  #include "mutt_menu.h"
>  #include "mutt_curses.h"
> -- 
> 1.7.10.4

-- 
David Champion • d...@bikeshed.us


Re: [PATCH 4/4] version.sh: Get detailed version info from git

2012-12-14 Thread David Champion
This is good to add support for, but note that the ${a#b} and ${a%b}
family of parameter expressions is nonportable.  These are commonly
accepted bashisms that also work in zsh, but not in xpg4 shells.

Can you redo with seds, or something?

* On 13 Dec 2012, Aaron Schrab wrote: 
> From: Aaron Schrab 
> 
> If not able to use mercurial to build a detailed version string, try
> using git to do so.
> ---
>  version.sh |   26 ++
>  1 file changed, 26 insertions(+)
> 
> diff --git a/version.sh b/version.sh
> index 39709a0..54568ac 100644
> --- a/version.sh
> +++ b/version.sh
> @@ -64,6 +64,32 @@ if [ -d .hg ] && $HG >/dev/null 2>&1; then
>   exit 0
>  fi
>  
> +# If in a git repo, and git is present use that to build detailed version 
> string
> +if git rev-parse 2> /dev/null; then
> + version=`git describe --long --dirty --tags --match mutt-*-rel`
> +
> + case "$version" in
> +   *-dirty)
> + dirty=+
> + version=${version%-dirty}
> + ;;
> + esac
> +
> + commit=${version##*-}
> + version=${version%-*}
> +
> + distance=${version##*-}
> + version=${version%-*}
> +
> + version=${version#mutt-}
> + version=${version%-rel}
> +
> + version=`echo $version | tr - .`
> +
> + echo "$version+$distance ($commit$dirty)"
> + exit 0
> +fi
> +
>  # If nothing else worked, just cat the VERSION file;
>  # it contains the latest release number.
>  cat VERSION
> -- 
> 1.7.10.4

-- 
David Champion • d...@bikeshed.us


Re: [PATCH 2/4] Generate version string during make not configure

2012-12-14 Thread Aaron Schrab

At 18:06 -0600 14 Dec 2012, David Champion  wrote:

+version.h: FORCE
+   echo '#define MUTT_VERSION "'`sh "$(srcdir)/version.sh"`'"' > $@.tmp
+   (cmp -s $@ $@.tmp) && rm -f $@.tmp || mv $@.tmp $@
+FORCE:
+


.PHONY: version.h ?


I did it that way to try to be more portable.  The docs for gnu make 
state:


Using `.PHONY' is more explicit and more efficient.  However, other
versions of `make' do not support `.PHONY'; thus `FORCE' appears in
many makefiles.


Re: [PATCH 4/4] version.sh: Get detailed version info from git

2012-12-14 Thread Aaron Schrab

At 18:10 -0600 14 Dec 2012, David Champion  wrote:

This is good to add support for, but note that the ${a#b} and ${a%b}
family of parameter expressions is nonportable.  These are commonly
accepted bashisms that also work in zsh, but not in xpg4 shells.

Can you redo with seds, or something?


I hadn't realized that those weren't portable.  I did the testing with 
dash to try to avoid, bash-specific features but of course that supports 
some non-standard features itself.


Updated version of that patch using sed instead follows.

 8< --

Subject: [PATCH] version.sh: Get detailed version info from git

If not able to use mercurial to build a detailed version string, try
using git to do so.
---
version.sh |   23 +++
1 file changed, 23 insertions(+)

diff --git a/version.sh b/version.sh
index 39709a0..35e5604 100644
--- a/version.sh
+++ b/version.sh
@@ -64,6 +64,29 @@ if [ -d .hg ] && $HG >/dev/null 2>&1; then
exit 0
fi

+# If in a git repo, and git is present use that to build detailed version 
string
+if git rev-parse 2> /dev/null; then
+   version=`git describe --long --dirty --tags --match 'mutt-*-rel'`
+
+   case "$version" in
+ *-dirty)
+   dirty=+
+   version=`echo $version | sed -e s/-dirty//`
+   ;;
+   esac
+
+   commit=`  echo $version|sed -e's/.*-//'`
+   version=` echo $version|sed -e's/-[^-]*$//'`
+
+   distance=`echo $version|sed -e's/.*-//'`
+   version=` echo $version|sed -e's/-[^-]*$//'`
+
+   version=` echo $version|sed -e's/^mutt-//' -e's/-rel$//' -e'y/-/./'`
+
+   echo "$version+$distance ($commit$dirty)"
+   exit 0
+fi
+
# If nothing else worked, just cat the VERSION file;
# it contains the latest release number.
cat VERSION
--
1.7.10.4



Re: [PATCH 2/4] Generate version string during make not configure

2012-12-14 Thread David Champion
* On 14 Dec 2012, Aaron Schrab wrote: 
> >.PHONY: version.h ?
> 
> I did it that way to try to be more portable.  The docs for gnu make state:
> 
>   Using `.PHONY' is more explicit and more efficient.  However, other
>   versions of `make' do not support `.PHONY'; thus `FORCE' appears in
>   many makefiles.

That's good.  If mutt still supports non-GNU makes we should leave it
that way.  Building from CVS (hg) has required GNU for so long I no
longer think of as optional. :/

-- 
David Champion • d...@bikeshed.us


Re: [PATCH 4/4] version.sh: Get detailed version info from git

2012-12-14 Thread David Champion
* On 14 Dec 2012, Aaron Schrab wrote: 
> At 18:10 -0600 14 Dec 2012, David Champion  wrote:
> >This is good to add support for, but note that the ${a#b} and ${a%b}
> >family of parameter expressions is nonportable.  These are commonly
> >accepted bashisms that also work in zsh, but not in xpg4 shells.
> >
> >Can you redo with seds, or something?
> 
> I hadn't realized that those weren't portable.  I did the testing with dash
> to try to avoid, bash-specific features but of course that supports some
> non-standard features itself.
> 
> Updated version of that patch using sed instead follows.

Thanks.  I'll leave this for a little while for others to comment.  Is
there anyone else who's building from git and can double-check this?

>  8< --
> 
> Subject: [PATCH] version.sh: Get detailed version info from git
> 
> If not able to use mercurial to build a detailed version string, try
> using git to do so.
> ---
> version.sh |   23 +++
> 1 file changed, 23 insertions(+)
> 
> diff --git a/version.sh b/version.sh
> index 39709a0..35e5604 100644
> --- a/version.sh
> +++ b/version.sh
> @@ -64,6 +64,29 @@ if [ -d .hg ] && $HG >/dev/null 2>&1; then
>   exit 0
> fi
> 
> +# If in a git repo, and git is present use that to build detailed version 
> string
> +if git rev-parse 2> /dev/null; then
> + version=`git describe --long --dirty --tags --match 'mutt-*-rel'`
> +
> + case "$version" in
> +   *-dirty)
> + dirty=+
> + version=`echo $version | sed -e s/-dirty//`
> + ;;
> + esac
> +
> + commit=`  echo $version|sed -e's/.*-//'`
> + version=` echo $version|sed -e's/-[^-]*$//'`
> +
> + distance=`echo $version|sed -e's/.*-//'`
> + version=` echo $version|sed -e's/-[^-]*$//'`
> +
> + version=` echo $version|sed -e's/^mutt-//' -e's/-rel$//' -e'y/-/./'`
> +
> + echo "$version+$distance ($commit$dirty)"
> + exit 0
> +fi
> +
> # If nothing else worked, just cat the VERSION file;
> # it contains the latest release number.
> cat VERSION
> -- 
> 1.7.10.4

-- 
David Champion • d...@bikeshed.us


Re: [PATCH 2/4] Generate version string during make not configure

2012-12-14 Thread Aaron Schrab

At 19:25 -0600 14 Dec 2012, David Champion  wrote:

That's good.  If mutt still supports non-GNU makes we should leave it
that way.  Building from CVS (hg) has required GNU for so long I no
longer think of as optional. :/


I don't know if it actually works, but the `INSTALL` file implies that 
they're supported by saying:


Please note that "VPATH" builds currently only work with GNU make