char cmd[LONG_STRING];
endwin ();
- mutt_expand_fmt (cmd, sizeof (cmd), editor, data);
+ mutt_expand_file_fmt (cmd, sizeof (cmd), editor, data);
mutt_system (cmd);
keypad (stdscr, TRUE);
clearok (stdscr, TRUE);
char cmd[STRING];
endwin ();
- mutt_expand_fmt (cmd, sizeof(cmd), Pager, tempfile);
+ mutt_expand_file_fmt (cmd, sizeof(cmd), Pager, tempfile);
mutt_system (cmd);
mutt_unlink (tempfile);
rc = 0;
return 0;
}
+void mutt_expand_file_fmt (char *dest, size_t destlen, const char *fmt, const char *src)
+{
+ char *_src = mutt_quote_filename(src);
+
+ mutt_expand_fmt(dest, destlen, fmt, _src);
+ safe_free((void **) &_src);
+}
+
void mutt_expand_fmt (char *dest, size_t destlen, const char *fmt, const char *src)
{
const char *p = fmt;
const char *last = p;
size_t len;
- char *_src;
size_t slen;
int found = 0;
- /* some rationale should be given here: mutt's quoting
- * rules are similar enough to the shell's rules so we
- * can use mutt_quote_filename() even for patterns.
- */
-
- _src = mutt_quote_filename(src);
- slen = strlen (_src);
+ slen = strlen (src);
while ((p = strchr (p, '%')) != NULL)
{
}
}
- strfcpy (dest, _src, destlen);
+ strfcpy (dest, src, destlen);
if (slen > destlen)
{
/* no more room */
if (found)
strfcpy (dest, last, destlen);
else
- snprintf (dest, destlen, "%s %s", fmt, _src);
+ snprintf (dest, destlen, "%s %s", fmt, src);
- FREE(&_src);
}
static int
return (-1);
}
+static void quote_simple(char *tmp, size_t len, const char *p)
+{
+ int i = 0;
+
+ tmp[i++] = '"';
+ while (*p && i < len - 2)
+ {
+ if (*p == '\\' || *p == '"')
+ tmp[i++] = '\\';
+ tmp[i++] = *p++;
+ }
+ tmp[i++] = '"';
+ tmp[i] = 0;
+}
+
/* convert a simple search into a real request */
void mutt_check_simple (char *s, size_t len, const char *simple)
{
strfcpy (s, "~U", len);
else
{
- const char *p = s;
- int i = 0;
-
- tmp[i++] = '"';
- while (*p && i < sizeof (tmp) - 2)
- {
- if (*p == '\\' || *p == '"')
- tmp[i++] = '\\';
- tmp[i++] = *p++;
- }
- tmp[i++] = '"';
- tmp[i] = 0;
+ quote_simple (tmp, sizeof(tmp), s);
mutt_expand_fmt (s, len, simple, tmp);
}
}
void mutt_curses_error (const char *, ...);
void mutt_enter_command (void);
void mutt_exit (int);
+void mutt_expand_file_fmt (char *, size_t, const char *, const char *);
void mutt_expand_fmt (char *, size_t, const char *, const char *);
void mutt_expand_link (char *, const char *, const char *);
void mutt_fetchPopMail (void);
int l;
- mutt_expand_fmt (cmd, sizeof(cmd), QueryCmd, s);
+ mutt_expand_file_fmt (cmd, sizeof(cmd), QueryCmd, s);
if ((thepid = mutt_create_filter (cmd, NULL, &fp, NULL)) < 0)
{