Added escape char possibility to "\#" for substitutions

SVN revision: 2449
This commit is contained in:
Stefan Ritt 2012-04-10 13:51:44 +00:00
parent 96d77ffed1
commit 69c0cd4a41

View File

@ -8650,7 +8650,7 @@ void get_auto_index(LOGBOOK * lbs, int index, char *format, char *retstr, int si
auto-increment tags */ auto-increment tags */
{ {
int i, message_id, loc, len, old_index; int i, message_id, loc, len, old_index;
char str[NAME_LENGTH], attrib[MAX_N_ATTR][NAME_LENGTH], att[MAX_ATTACHMENTS][256]; char *p, str[NAME_LENGTH], attrib[MAX_N_ATTR][NAME_LENGTH], att[MAX_ATTACHMENTS][256];
time_t now; time_t now;
if (strchr(format, '%') == NULL && strchr(format, '#') == NULL) { if (strchr(format, '%') == NULL && strchr(format, '#') == NULL) {
@ -8661,9 +8661,15 @@ void get_auto_index(LOGBOOK * lbs, int index, char *format, char *retstr, int si
time(&now); time(&now);
my_strftime(retstr, size, format, localtime(&now)); my_strftime(retstr, size, format, localtime(&now));
if (strchr(retstr, '#') == NULL) p = strchr(retstr, '#');
if (p == NULL)
return; return;
if (p > retstr && *(p-1) == '\\') { // escape
memmove(p-1, p, strlen(p)+1);
return;
}
/* record location and length of ###'s */ /* record location and length of ###'s */
for (i = loc = 0, len = 1; i < (int) strlen(retstr); i++) { for (i = loc = 0, len = 1; i < (int) strlen(retstr); i++) {
if (retstr[i] == '#') { if (retstr[i] == '#') {