Changeset 985 for trunk/dll/command.c
- Timestamp:
- Mar 1, 2008, 2:37:14 AM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/dll/command.c
r959 r985 22 22 20 Aug 07 GKY Move #pragma alloc_text to end for OpenWatcom compat 23 23 06 Jan 08 GKY Use NormalizeCmdLine to check program strings on entry 24 29 Feb 08 GKY Changes to enable user settable command line length 25 29 Feb 08 GKY Use xfree where appropriate 24 26 25 27 ***********************************************************************/ … … 44 46 typedef struct 45 47 { 46 CHAR cl[MAXCOMLINESTRG];48 PSZ pszCmdLine; 47 49 INT flags; 48 50 CHAR title[34]; … … 307 309 xfree(info->title); 308 310 xfree(info->cl); 309 free(info);311 xfree(info); 310 312 info = next; 311 313 } … … 355 357 xfree(info->cl); 356 358 xfree(info->title); 357 free(info);359 xfree(info); 358 360 break; 359 361 } … … 404 406 LINKCMDS *info; 405 407 406 if (!addme || !*addme-> cl|| !*addme->title)408 if (!addme || !*addme->pszCmdLine || !*addme->title) 407 409 return NULL; // No data 408 410 info = cmdhead; … … 415 417 if (!info) 416 418 return NULL; 417 info->cl = xstrdup(addme-> cl, pszSrcFile, __LINE__);419 info->cl = xstrdup(addme->pszCmdLine, pszSrcFile, __LINE__); 418 420 info->title = xstrdup(addme->title, pszSrcFile, __LINE__); 419 421 if (addme->flags) … … 422 424 xfree(info->cl); 423 425 xfree(info->title); 424 free(info);426 xfree(info); 425 427 return NULL; 426 428 } … … 459 461 xfree(info->cl); 460 462 xfree(info->title); 461 free(info);463 xfree(info); 462 464 return TRUE; 463 465 } … … 622 624 APIRET ret; 623 625 624 pszWorkBuf = xmalloc(MAXCOMLINESTRG, pszSrcFile, __LINE__); 625 if (!pszWorkBuf) 626 memset(&temp, 0, sizeof(COMMAND)); 627 temp.pszCmdLine = xmallocz(MaxComLineStrg, pszSrcFile, __LINE__); 628 if (!temp.pszCmdLine) 626 629 break; //already complained 627 memset(&temp, 0, sizeof(COMMAND)); 628 WinQueryDlgItemText(hwnd, CMD_CL, sizeof(temp.cl), temp.cl); 629 NormalizeCmdLine(pszWorkBuf, temp.cl); 630 memcpy(temp.cl, pszWorkBuf, strlen(pszWorkBuf) + 1); 630 pszWorkBuf = xmalloc(MaxComLineStrg, pszSrcFile, __LINE__); 631 if (!pszWorkBuf) { 632 xfree(temp.pszCmdLine); 633 break; //already complained 634 } 635 WinQueryDlgItemText(hwnd, CMD_CL, MaxComLineStrg, temp.pszCmdLine); 636 NormalizeCmdLine(pszWorkBuf, temp.pszCmdLine); 637 memcpy(temp.pszCmdLine, pszWorkBuf, strlen(pszWorkBuf) + 1); 631 638 xfree(pszWorkBuf); 632 if (!strchr(temp. cl, '%')){639 if (!strchr(temp.pszCmdLine, '%')){ 633 640 ret = saymsg(MB_YESNO, 634 641 HWND_DESKTOP, … … 636 643 GetPString(IDS_TOACTONSELECTEDTEXT)); 637 644 if (ret == MBID_YES) 638 strcat(temp. cl, " %a");645 strcat(temp.pszCmdLine, " %a"); 639 646 } 640 647 WinQueryDlgItemText(hwnd, CMD_TITLE, sizeof(temp.title), temp.title); … … 657 664 if (fCancelAction){ 658 665 fCancelAction = FALSE; 666 xfree(temp.pszCmdLine); 659 667 break; 660 668 } … … 676 684 bstripcr(env); 677 685 if (*env) { 678 PrfWriteProfileString(fmprof, FM3Str, temp. cl, env);686 PrfWriteProfileString(fmprof, FM3Str, temp.pszCmdLine, env); 679 687 } 680 688 x = (SHORT) WinSendDlgItemMsg(hwnd, … … 694 702 save_commands(); 695 703 } 696 } 704 } 705 xfree(temp.pszCmdLine); 697 706 } 698 707 x = (SHORT) WinSendDlgItemMsg(hwnd, 699 708 CMD_LISTBOX, 700 709 LM_QUERYSELECTION, 701 710 MPFROMSHORT(LIT_FIRST), MPVOID); 702 711 WinDismissDlg(hwnd, 0); 703 712 break; … … 720 729 APIRET ret; 721 730 722 pszWorkBuf = xmalloc(MAXCOMLINESTRG, pszSrcFile, __LINE__); 723 if (!pszWorkBuf) 731 memset(&temp, 0, sizeof(COMMAND)); 732 temp.pszCmdLine = xmallocz(MaxComLineStrg, pszSrcFile, __LINE__); 733 if (!temp.pszCmdLine) 724 734 break; //already complained 725 memset(&temp, 0, sizeof(COMMAND)); 726 WinQueryDlgItemText(hwnd, CMD_CL, sizeof(temp.cl), temp.cl); 727 NormalizeCmdLine(pszWorkBuf, temp.cl); 728 memcpy(temp.cl, pszWorkBuf, strlen(pszWorkBuf) + 1); 735 pszWorkBuf = xmalloc(MaxComLineStrg, pszSrcFile, __LINE__); 736 if (!pszWorkBuf) { 737 xfree(temp.pszCmdLine); 738 break; //already complained 739 } 740 WinQueryDlgItemText(hwnd, CMD_CL, MaxComLineStrg, temp.pszCmdLine); 741 NormalizeCmdLine(pszWorkBuf, temp.pszCmdLine); 742 memcpy(temp.pszCmdLine, pszWorkBuf, strlen(pszWorkBuf) + 1); 729 743 xfree(pszWorkBuf); 730 if (!strchr(temp. cl, '%')){744 if (!strchr(temp.pszCmdLine, '%')){ 731 745 ret = saymsg(MB_YESNO, 732 746 HWND_DESKTOP, … … 734 748 GetPString(IDS_TOACTONSELECTEDTEXT)); 735 749 if (ret == MBID_YES) 736 strcat(temp. cl, " %a");750 strcat(temp.pszCmdLine, " %a"); 737 751 } 738 752 WinQueryDlgItemText(hwnd, CMD_TITLE, sizeof(temp.title), temp.title); … … 755 769 if (fCancelAction){ 756 770 fCancelAction = FALSE; 771 xfree(temp.pszCmdLine); 757 772 break; 758 773 } … … 770 785 bstripcr(env); 771 786 if (*env) { 772 PrfWriteProfileString(fmprof, FM3Str, temp. cl, env);787 PrfWriteProfileString(fmprof, FM3Str, temp.pszCmdLine, env); 773 788 } 774 789 x = (SHORT) WinSendDlgItemMsg(hwnd, … … 788 803 save_commands(); 789 804 } 790 } 805 } 806 xfree(temp.pszCmdLine); 791 807 } 792 808 break; … … 818 834 } 819 835 break; 836 820 837 case CMD_REPLACE: 821 838 { //Delete first … … 824 841 APIRET ret; 825 842 826 pszWorkBuf = xmalloc(M AXCOMLINESTRG, pszSrcFile, __LINE__);827 if (!pszWorkBuf) 843 pszWorkBuf = xmalloc(MaxComLineStrg, pszSrcFile, __LINE__); 844 if (!pszWorkBuf) { 828 845 break; //already complained 829 memset(&temp, 0, sizeof(COMMAND)); 830 WinQueryDlgItemText(hwnd, CMD_CL, sizeof(temp.cl), temp.cl); 831 NormalizeCmdLine(pszWorkBuf, temp.cl); 832 memcpy(temp.cl, pszWorkBuf, strlen(pszWorkBuf) + 1); 846 } 847 memset(&temp, 0, sizeof(COMMAND)); 848 temp.pszCmdLine = xmallocz(MaxComLineStrg, pszSrcFile, __LINE__); 849 if (!temp.pszCmdLine) { 850 xfree(pszWorkBuf); 851 break; //already complained 852 } 853 WinQueryDlgItemText(hwnd, CMD_CL, MaxComLineStrg, temp.pszCmdLine); 854 NormalizeCmdLine(pszWorkBuf, temp.pszCmdLine); 855 memcpy(temp.pszCmdLine, pszWorkBuf, strlen(pszWorkBuf) + 1); 833 856 xfree(pszWorkBuf); 834 857 if (fCancelAction){ 835 858 fCancelAction = FALSE; 859 xfree(temp.pszCmdLine); 836 860 break; 837 861 } 838 if (!strchr(temp. cl, '%')){862 if (!strchr(temp.pszCmdLine, '%')){ 839 863 ret = saymsg(MB_YESNO, 840 864 HWND_DESKTOP, … … 842 866 GetPString(IDS_TOACTONSELECTEDTEXT)); 843 867 if (ret == MBID_YES) 844 strcat(temp. cl, " %a");868 strcat(temp.pszCmdLine, " %a"); 845 869 } 846 870 //remember item location in the list … … 896 920 bstripcr(env); 897 921 if (*env) { 898 PrfWriteProfileString(fmprof, FM3Str, temp. cl, env);922 PrfWriteProfileString(fmprof, FM3Str, temp.pszCmdLine, env); 899 923 } //put item back in original place 900 924 x = (SHORT) WinSendDlgItemMsg(hwnd, … … 947 971 } 948 972 } 973 xfree(temp.pszCmdLine); 949 974 } 950 975 break;
Note:
See TracChangeset
for help on using the changeset viewer.