Changeset 1431:f82b38f77f48
- Timestamp:
- 2000-01-10 02:35:48 (9 years ago)
- Author:
- Thomas Roessler <roessler@…>
- Branch:
- HEAD
- Message:
-
Add (and use) a function mutt_str_replace, which essentially
replaces the sequence:
safe_free (&s);
s = safe_strdup (t);
- Files:
-
Legend:
- Unmodified
- Added
- Removed
-
|
r1423
|
r1431
|
|
| 66 | 66 | { |
| 67 | 67 | mutt_copy_stream (fpin, fpout); |
| 68 | | FREE(&a->filename); |
| 69 | | a->filename = safe_strdup(tempfile); |
| | 68 | mutt_str_replace (&a->filename, tempfile); |
| 70 | 69 | a->unlink = 1; |
| 71 | 70 | |
-
|
r1423
|
r1431
|
|
| 933 | 933 | else |
| 934 | 934 | { |
| 935 | | safe_free ((void **) &Mask.pattern); |
| | 935 | mutt_str_replace (&Mask.pattern, buf); |
| 936 | 936 | regfree (Mask.rx); |
| 937 | 937 | safe_free ((void **) &Mask.rx); |
| 938 | | Mask.pattern = safe_strdup (buf); |
| 939 | 938 | Mask.rx = rx; |
| 940 | 939 | Mask.not = not; |
-
|
r1426
|
r1431
|
|
| 153 | 153 | { |
| 154 | 154 | snprintf (input_signas, sizeof (input_signas), "0x%s", pgp_keyid (p)); |
| 155 | | safe_free((void **) &PgpSignAs); PgpSignAs = safe_strdup (input_signas); |
| 156 | | safe_free((void **) &PgpSignMicalg); PgpSignMicalg = safe_strdup (pgp_pkalg_to_mic (p->algorithm)); |
| | 155 | mutt_str_replace (&PgpSignAs, input_signas); |
| | 156 | mutt_str_replace (&PgpSignMicalg, pgp_pkalg_to_mic (p->algorithm)); |
| 157 | 157 | pgp_free_key (&p); |
| 158 | 158 | |
| … |
… |
|
| 189 | 189 | } |
| 190 | 190 | else |
| 191 | | { |
| 192 | | safe_free ((void **) &PgpSignMicalg); |
| 193 | | PgpSignMicalg = safe_strdup (input_micalg); |
| 194 | | } |
| | 191 | mutt_str_replace (&PgpSignMicalg, input_micalg); |
| 195 | 192 | } |
| 196 | 193 | } |
| … |
… |
|
| 488 | 485 | if (mutt_get_field ("Subject: ", buf, sizeof (buf), 0) == 0) |
| 489 | 486 | { |
| 490 | | safe_free ((void **) &msg->env->subject); |
| 491 | | msg->env->subject = safe_strdup (buf); |
| | 487 | mutt_str_replace (&msg->env->subject, buf); |
| 492 | 488 | move (HDR_SUBJECT, HDR_XOFFSET); |
| 493 | 489 | clrtoeol (); |
| … |
… |
|
| 826 | 822 | if (mutt_get_field ("Description: ", buf, sizeof (buf), 0) == 0) |
| 827 | 823 | { |
| 828 | | safe_free ((void **) &idx[menu->current]->content->description); |
| 829 | | idx[menu->current]->content->description = safe_strdup (buf); |
| | 824 | mutt_str_replace (&idx[menu->current]->content->description, buf); |
| 830 | 825 | menu->redraw = REDRAW_CURRENT; |
| 831 | 826 | } |
| … |
… |
|
| 965 | 960 | break; |
| 966 | 961 | |
| 967 | | safe_free ((void **) &idx[menu->current]->content->filename); |
| 968 | | idx[menu->current]->content->filename = safe_strdup (fname); |
| | 962 | mutt_str_replace (&idx[menu->current]->content->filename, fname); |
| 969 | 963 | menu->redraw = REDRAW_CURRENT; |
| 970 | 964 | |
| … |
… |
|
| 1037 | 1031 | |
| 1038 | 1032 | idx[menu->current]->content->type = itype; |
| 1039 | | safe_free ((void **) &idx[menu->current]->content->subtype); |
| 1040 | | idx[menu->current]->content->subtype = safe_strdup (p); |
| | 1033 | mutt_str_replace (&idx[menu->current]->content->subtype, p); |
| 1041 | 1034 | idx[menu->current]->content->unlink = 1; |
| 1042 | 1035 | menu->redraw |= REDRAW_INDEX | REDRAW_STATUS; |
-
|
r1426
|
r1431
|
|
| 919 | 919 | if (Context) |
| 920 | 920 | { |
| 921 | | FREE (&LastFolder); |
| 922 | | LastFolder = safe_strdup (Context->path); |
| 923 | | } |
| 924 | | |
| 925 | | if (Context) |
| 926 | | { |
| | 921 | mutt_str_replace (&LastFolder, Context->path); |
| | 922 | |
| 927 | 923 | if (mx_close_mailbox (Context) != 0) |
| 928 | 924 | { |
-
|
r1423
|
r1431
|
|
| 254 | 254 | strfcpy (tmp, e->subject ? e->subject: "", sizeof (tmp)); |
| 255 | 255 | if (mutt_enter_string ((unsigned char *) tmp, sizeof (tmp), LINES-1, 9, 0) == 0) |
| 256 | | { |
| 257 | | safe_free ((void **) &e->subject); |
| 258 | | e->subject = safe_strdup (tmp); |
| 259 | | } |
| | 256 | mutt_str_replace (&e->subject, tmp); |
| 260 | 257 | addch ('\n'); |
| 261 | 258 | } |
| … |
… |
|
| 392 | 389 | break; |
| 393 | 390 | case 's': |
| 394 | | safe_free ((void **) &msg->env->subject); |
| 395 | | msg->env->subject = safe_strdup (p); |
| | 391 | mutt_str_replace (&msg->env->subject, p); |
| 396 | 392 | break; |
| 397 | 393 | case 't': |
-
|
r1196
|
r1431
|
|
| 80 | 80 | if (!h->hist[prev] || mutt_strcmp (h->hist[prev], s) != 0) |
| 81 | 81 | { |
| 82 | | safe_free ((void **) &h->hist[h->last]); |
| 83 | | h->hist[h->last++] = safe_strdup (s); |
| | 82 | mutt_str_replace (&h->hist[h->last++], s); |
| 84 | 83 | if (h->last > HistSize - 1) |
| 85 | 84 | h->last = 0; |
-
|
r1423
|
r1431
|
|
| 654 | 654 | case DT_STR: |
| 655 | 655 | if (p->init) |
| 656 | | { |
| 657 | | FREE (p->data); |
| 658 | | *((char **) p->data) = safe_strdup ((char *) p->init); |
| 659 | | } |
| | 656 | mutt_str_replace ((char **) p->data, (char *) p->init); |
| 660 | 657 | break; |
| 661 | 658 | case DT_PATH: |
| … |
… |
|
| 664 | 661 | char path[_POSIX_PATH_MAX]; |
| 665 | 662 | |
| 666 | | FREE (p->data); |
| 667 | 663 | strfcpy (path, (char *) p->init, sizeof (path)); |
| 668 | 664 | mutt_expand_path (path, sizeof (path)); |
| 669 | | *((char **) p->data) = safe_strdup (path); |
| | 665 | mutt_str_replace ((char **) p->data, path); |
| 670 | 666 | } |
| 671 | 667 | break; |
-
|
r1423
|
r1431
|
|
| 144 | 144 | } |
| 145 | 145 | |
| | 146 | void mutt_str_replace (char **p, const char *s) |
| | 147 | { |
| | 148 | if (*p) |
| | 149 | free (*p); |
| | 150 | *p = safe_strdup (s); |
| | 151 | } |
| | 152 | |
| 146 | 153 | /* convert all characters in the string to lowercase */ |
| 147 | 154 | char *mutt_strlower (char *s) |
-
|
r1423
|
r1431
|
|
| 397 | 397 | |
| 398 | 398 | case 'F': |
| 399 | | FREE (&Muttrc); |
| 400 | | Muttrc = safe_strdup (optarg); |
| | 399 | mutt_str_replace (&Muttrc, optarg); |
| 401 | 400 | break; |
| 402 | 401 | |
-
|
r1423
|
r1431
|
|
| 659 | 659 | buf, sizeof (buf), M_CLEAR) != 0 || !buf[0]) |
| 660 | 660 | return (-1); |
| 661 | | safe_free ((void **) &menu->searchBuf); |
| 662 | | menu->searchBuf = safe_strdup (buf); |
| | 661 | mutt_str_replace (&menu->searchBuf, buf); |
| 663 | 662 | menu->searchDir = (op == OP_SEARCH) ? M_SEARCH_DOWN : M_SEARCH_UP; |
| 664 | 663 | } |
-
|
r1423
|
r1431
|
|
| 501 | 501 | { |
| 502 | 502 | if (hdr) |
| 503 | | { |
| 504 | | FREE (&hdr->path); |
| 505 | | hdr->path = safe_strdup (path); |
| 506 | | } |
| | 503 | mutt_str_replace (&hdr->path, path); |
| 507 | 504 | FREE (&msg->path); |
| 508 | 505 | return 0; |
| … |
… |
|
| 576 | 573 | { |
| 577 | 574 | if (hdr) |
| 578 | | { |
| 579 | | FREE (&hdr->path); |
| 580 | | hdr->path = safe_strdup (tmp); |
| 581 | | } |
| | 575 | mutt_str_replace (&hdr->path, tmp); |
| 582 | 576 | FREE (&msg->path); |
| 583 | 577 | return 0; |
| … |
… |
|
| 649 | 643 | snprintf (newpath, _POSIX_PATH_MAX, "%s/%s", ctx->path, h->path); |
| 650 | 644 | if ((rc = safe_rename (newpath, oldpath)) == 0) |
| 651 | | { |
| 652 | | FREE (&h->path); |
| 653 | | h->path = safe_strdup (partpath); |
| 654 | | } |
| | 645 | mutt_str_replace (&h->path, partpath); |
| 655 | 646 | } |
| 656 | 647 | } |
| … |
… |
|
| 720 | 711 | return (-1); |
| 721 | 712 | } |
| 722 | | safe_free ((void **) &h->path); |
| 723 | | h->path = safe_strdup (partpath); |
| | 713 | mutt_str_replace (&h->path, partpath); |
| 724 | 714 | } |
| 725 | 715 | return (0); |
| … |
… |
|
| 929 | 919 | |
| 930 | 920 | if(mutt_strcmp(ctx->hdrs[i]->path, p->h->path)) |
| 931 | | { |
| 932 | | safe_free((void **) &ctx->hdrs[i]->path); |
| 933 | | ctx->hdrs[i]->path = safe_strdup(p->h->path); |
| 934 | | } |
| | 921 | mutt_str_replace (&ctx->hdrs[i]->path, p->h->path); |
| 935 | 922 | |
| 936 | 923 | if(modified) |
-
|
r1423
|
r1431
|
|
| 404 | 404 | if (mutt_strcasecmp (attribute, q->attribute) == 0) |
| 405 | 405 | { |
| 406 | | safe_free((void **) &q->value); |
| 407 | | q->value = safe_strdup(value); |
| | 406 | mutt_str_replace (&q->value, value); |
| 408 | 407 | return; |
| 409 | 408 | } |
-
|
r1424
|
r1431
|
|
| 349 | 349 | * specified. |
| 350 | 350 | */ |
| 351 | | safe_free ((void **) &ct->filename); |
| 352 | | ct->filename = safe_strdup (s); |
| | 351 | mutt_str_replace (&ct->filename, s); |
| 353 | 352 | } |
| 354 | 353 | if ((s = mutt_get_parameter ("name", parms)) != 0) |
| … |
… |
|
| 407 | 406 | else if (!mutt_strcasecmp ("description", line + 8)) |
| 408 | 407 | { |
| 409 | | safe_free ((void **) &p->description); |
| 410 | | p->description = safe_strdup (c); |
| | 408 | mutt_str_replace (&p->description, c); |
| 411 | 409 | rfc2047_decode (p->description, p->description, mutt_strlen (p->description) + 1); |
| 412 | 410 | } |
| … |
… |
|
| 456 | 454 | { |
| 457 | 455 | b->type = TYPETEXT; |
| 458 | | safe_free ((void **) &b->subtype); |
| 459 | | b->subtype = safe_strdup ("plain"); |
| | 456 | mutt_str_replace (&b->subtype, "plain"); |
| 460 | 457 | } |
| 461 | 458 | } |
| … |
… |
|
| 989 | 986 | if (hdr) |
| 990 | 987 | { |
| 991 | | safe_free ((void **) &hdr->content->description); |
| 992 | | hdr->content->description = safe_strdup (p); |
| | 988 | mutt_str_replace (&hdr->content->description, p); |
| 993 | 989 | rfc2047_decode (hdr->content->description, |
| 994 | 990 | hdr->content->description, |
| … |
… |
|
| 1009 | 1005 | if (!mutt_strcasecmp ("ate", line + 1)) |
| 1010 | 1006 | { |
| 1011 | | safe_free((void **)&e->date); |
| 1012 | | e->date = safe_strdup(p); |
| | 1007 | mutt_str_replace (&e->date, p); |
| 1013 | 1008 | if (hdr) |
| 1014 | 1009 | hdr->date_sent = mutt_parse_date (p, hdr); |
-
|
r1405
|
r1431
|
|
| 619 | 619 | { |
| 620 | 620 | if (l) |
| 621 | | { |
| 622 | | safe_free ((void **) &l->dflt); |
| 623 | | l->dflt = safe_strdup (resp); |
| 624 | | } |
| | 621 | mutt_str_replace (&l->dflt, resp); |
| 625 | 622 | else |
| 626 | 623 | { |
-
|
r1423
|
r1431
|
|
| 483 | 483 | |
| 484 | 484 | if (set_signas || *pgp_sign_as) |
| 485 | | { |
| 486 | | safe_free((void **) &PgpSignAs); |
| 487 | | PgpSignAs = safe_strdup(pgp_sign_as); |
| 488 | | } |
| | 485 | mutt_str_replace (&PgpSignAs, pgp_sign_as); |
| 489 | 486 | |
| 490 | 487 | /* the micalg field must not be empty */ |
| 491 | 488 | if (set_signas && *pgp_sign_micalg) |
| 492 | | { |
| 493 | | safe_free((void **) &PgpSignMicalg); |
| 494 | | PgpSignMicalg = safe_strdup(pgp_sign_micalg); |
| 495 | | } |
| | 489 | mutt_str_replace (&PgpSignMicalg, pgp_sign_micalg); |
| 496 | 490 | |
| 497 | 491 | return pgp; |
| … |
… |
|
| 625 | 619 | } |
| 626 | 620 | |
| 627 | | safe_free ((void *) &b->filename); |
| 628 | | b->filename = safe_strdup (file); |
| | 621 | mutt_str_replace (&b->filename, file); |
| 629 | 622 | b->unlink = 1; |
| 630 | 623 | |
-
|
r1426
|
r1431
|
|
| 195 | 195 | void mutt_signal_init (void); |
| 196 | 196 | void mutt_stamp_attachment (BODY *a); |
| | 197 | void mutt_str_replace (char **p, const char *s); |
| 197 | 198 | void mutt_tabs_to_spaces (char *); |
| 198 | 199 | void mutt_tag_set_flag (int, int); |
-
|
r1426
|
r1431
|
|
| 89 | 89 | { |
| 90 | 90 | if (mutt_strcmp (idx[x]->tree, buf) != 0) |
| 91 | | { |
| 92 | | safe_free ((void **) &idx[x]->tree); |
| 93 | | idx[x]->tree = safe_strdup (buf); |
| 94 | | } |
| | 91 | mutt_str_replace (&idx[x]->tree, buf); |
| 95 | 92 | } |
| 96 | 93 | else |
-
|
r1423
|
r1431
|
|
| 151 | 151 | field++; |
| 152 | 152 | field = mutt_skip_whitespace (field); |
| 153 | | safe_free ((void **) entry); |
| 154 | | *entry = safe_strdup (field); |
| | 153 | mutt_str_replace (entry, field); |
| 155 | 154 | } |
| 156 | 155 | return 1; |
-
|
r1423
|
r1431
|
|
| 260 | 260 | { |
| 261 | 261 | rfc2047_encode_string (buffer, sizeof (buffer), (const unsigned char *)ptr->personal); |
| 262 | | safe_free ((void **) &ptr->personal); |
| 263 | | ptr->personal = safe_strdup (buffer); |
| | 262 | mutt_str_replace (&ptr->personal, buffer); |
| 264 | 263 | } |
| 265 | 264 | #ifdef EXACT_ADDRESS |
| … |
… |
|
| 267 | 266 | { |
| 268 | 267 | rfc2047_encode_string (buffer, sizeof (buffer), (const unsigned char *)ptr->val); |
| 269 | | safe_free ((void **) &ptr->val); |
| 270 | | ptr->val = safe_strdup (buffer); |
| | 268 | mutt_str_replace (&ptr->val, buffer); |
| 271 | 269 | } |
| 272 | 270 | #endif |
-
|
r1423
|
r1431
|
|
| 235 | 235 | return (-1); |
| 236 | 236 | } |
| 237 | | safe_free ((void **) &en->subject); |
| 238 | | en->subject = safe_strdup (buf); |
| | 237 | mutt_str_replace (&en->subject, buf); |
| 239 | 238 | |
| 240 | 239 | return 0; |
| … |
… |
|
| 915 | 914 | { |
| 916 | 915 | rfc2047_encode_string (tmp, sizeof (tmp), (unsigned char *) t->description); |
| 917 | | safe_free ((void **) &t->description); |
| 918 | | t->description = safe_strdup (tmp); |
| | 916 | mutt_str_replace (&t->description, tmp); |
| 919 | 917 | } |
| 920 | 918 | if (t->parts) |
-
|
r1423
|
r1431
|
|
| 1382 | 1382 | len = mutt_strlen (tmp); |
| 1383 | 1383 | rfc2047_encode_string (tmp + len, sizeof (tmp) - len, (unsigned char *) p); |
| 1384 | | safe_free ((void **) &h->data); |
| 1385 | | h->data = safe_strdup (tmp); |
| | 1384 | mutt_str_replace (&h->data, tmp); |
| 1386 | 1385 | } |
| 1387 | 1386 | } |
| … |
… |
|
| 1812 | 1811 | rfc2047_encode_string (buffer, sizeof (buffer) - 1, |
| 1813 | 1812 | (unsigned char *) env->subject); |
| 1814 | | safe_free ((void **) &env->subject); |
| 1815 | | env->subject = safe_strdup (buffer); |
| | 1813 | mutt_str_replace (&env->subject, buffer); |
| 1816 | 1814 | } |
| 1817 | 1815 | encode_headers (env->userhdrs); |