Changeset 1840
Legend:
- Unmodified
- Added
- Removed
-
trunk/dll/errutil.c
r1722 r1840 7 7 8 8 Copyright (c) 1993-98 M. Kimes 9 Copyright (c) 2004, 201 4Steven H. Levine9 Copyright (c) 2004, 2015 Steven H. Levine 10 10 11 11 12 Aug 04 SHL Comments … … 42 42 16 Feb 14 GKY Rework readonly check on delete code so it actually works in a logical way 43 43 and so it works with move to trashcan inabled. 44 09 Nov 13 SHL Use GetTidForThread in DbgMsg and tweak for for editors that understand file:line 44 45 45 46 ***********************************************************************/ … … 61 62 #include "notebook.h" // fErrorBeepOff 62 63 #include "init.h" // Data declares 64 #include "misc.h" // GetTidForThread 63 65 #include "wrappers.h" // xmallocz 64 66 #include "fm3dll2.h" … … 81 83 VOID DbgMsg(PCSZ pszSrcFile, UINT uSrcLineNo, PCSZ pszFmt, ...) 82 84 { 83 PIB *ppib;84 TIB *ptib;85 85 ULONG ultid; 86 APIRET apiret;87 86 va_list va; 88 87 … … 106 105 #endif 107 106 108 apiret = DosGetInfoBlocks(&ptib, &ppib); 109 if (apiret) 110 ultid = 0; 111 else 112 ultid = ptib->tib_ptib2->tib2_ultid; 107 ultid = GetTidForThread(); 113 108 114 109 // OK for source file name to be null 115 fprintf(stderr, "%s %u (%lu)", pszSrcFile ? pszSrcFile : "n/a", uSrcLineNo, ultid); 110 // 2015-08-08 SHL Use file:line for editors that support it 111 fprintf(stderr, "%s:%u (%lu)", pszSrcFile ? pszSrcFile : "n/a", uSrcLineNo, ultid); 116 112 // If format null want just file and line 117 113 if (pszFmt) { -
trunk/dll/misc.c
r1835 r1840 6 6 7 7 Copyright (c) 1993-98 M. Kimes 8 Copyright (c) 2003, 201 0Steven H. Levine8 Copyright (c) 2003, 2015 Steven H. Levine 9 9 10 10 11 Jun 03 SHL Add JFS and FAT32 support … … 59 59 08 Mar 09 GKY Removed variable aurguments from docopyf and unlinkf (not used) 60 60 28 Mar 09 GKY Add RemoveOldCnrSwitches to remove pre 3.16 style ini keys; 61 61 add State.version key for check 62 62 12 Jul 09 GKY Add xDosQueryAppType and xDosAlloc... to allow FM/2 to load in high memory 63 63 22 Jul 09 GKY Check if drives support EAs add driveflag for this 64 64 22 Jul 09 GKY Allow .LONGNAME to be displayed for FAT drives. 65 65 21 Dec 09 GKY Allow command menu reorder without changing the "ID" or hot key for a command. 66 66 Added load_inicommand to load the IDs from the ini file. 67 67 17 JAN 10 GKY Changes to get working with Watcom 1.9 Beta (1/16/10). Mostly cast CHAR CONSTANT * as CHAR *. 68 68 23 Oct 10 GKY Add menu items for opening directory cnrs based on path of selected item 69 69 including the option to use walk directories to select path 70 70 26 Aug 11 GKY Add a low mem version of xDosAlloc* wrappers; move error checking into all the 71 71 xDosAlloc* wrappers. 72 72 12 Nov 11 GKY Fixed HelpViewer's failure to open help files and subsequent failure with files with spaces. 73 73 28 Jun 14 GKY Fix errors identified with CPPCheck 74 74 12 Jul 15 GKY Fix CN_REALLOCPSZ file name editing code to: 1) Eliminate the possibility of 75 updating the container before CN_ENDEDIT is called. 2) Don't call RemoveCnrItems 76 for tree container and collector. 75 updating the container before CN_ENDEDIT is called. 2) Don't call RemoveCnrItems 76 for tree container and collector. 77 09 Aug 15 SHL Expose GetTidForThread and rework usage 77 78 78 79 ***********************************************************************/ … … 163 164 TIB *ptib; 164 165 BOOL yes; 165 APIRET rc = DosGetInfoBlocks(&ptib, &ppib); 166 167 if (rc) { 168 Dos_Error(MB_CANCEL, rc, HWND_DESKTOP, pszSrcFile, __LINE__, 169 PCSZ_DOSGETINFOBLOCKS); 166 APIRET rc = xDosGetInfoBlocks(&ptib, &ppib); 167 168 if (rc) 170 169 yes = FALSE; 171 }172 170 else { 173 171 PID pid; … … 190 188 * window must exist and must be created by fm/2 191 189 * @param hwnd is window handle 192 * @returns thread ordinal or -1if error190 * @returns thread ordinal or 0 if error 193 191 */ 194 192 195 INT GetTidForWindow(HWND hwnd)193 UINT GetTidForWindow(HWND hwnd) 196 194 { 197 195 PIB *ppib; 198 196 TIB *ptib; 199 LONG ordinal = -1; 200 APIRET rc = DosGetInfoBlocks(&ptib, &ppib); 201 202 if (rc) { 203 Dos_Error(MB_CANCEL, rc, HWND_DESKTOP, pszSrcFile, __LINE__, 204 PCSZ_DOSGETINFOBLOCKS); 205 } 197 LONG ordinal; 198 APIRET rc = xDosGetInfoBlocks(&ptib, &ppib); 199 200 if (rc) 201 ordinal = 0; 206 202 else { 207 203 PID pid; 208 204 TID tid; 209 if (!WinQueryWindowProcess(hwnd, &pid, &tid)) 210 Win_Error(hwnd, HWND_DESKTOP, pszSrcFile, __LINE__, "WinQueryWindowProcess failed for %X", hwnd); 211 else if (pid != ppib->pib_ulpid) 212 Runtime_Error(pszSrcFile, __LINE__, "hwnd %X not created by fm/2", hwnd); 205 if (!WinQueryWindowProcess(hwnd, &pid, &tid)) { 206 ordinal = -1; 207 Win_Error(hwnd, HWND_DESKTOP, pszSrcFile, __LINE__, "WinQueryWindowProcess failed for hwnd %x", hwnd); 208 } 209 else if (pid != ppib->pib_ulpid) { 210 ordinal = 0; 211 Runtime_Error(pszSrcFile, __LINE__, "hwnd %x not created by fm/2 process", hwnd); 212 } 213 213 else 214 214 ordinal = ptib->tib_ptib2->tib2_ultid; … … 217 217 } 218 218 219 #endif // FORTIFY 220 219 221 /** 220 * Return thread ordinal for current thread 221 * @returns thread ordinal or -1 if error 222 * Return thread ordinal (1..n) for current thread 223 * @returns thread ordinal or 0 if error 224 * 2015-08-09 SHL changed return 222 225 */ 223 226 224 INT GetTidForThread(VOID)227 UINT GetTidForThread(VOID) 225 228 { 226 229 PIB *ppib; 227 230 TIB *ptib; 228 LONG ordinal = -1; 229 APIRET rc = DosGetInfoBlocks(&ptib, &ppib); 230 231 if (rc) { 232 Dos_Error(MB_CANCEL, rc, HWND_DESKTOP, pszSrcFile, __LINE__, 233 PCSZ_DOSGETINFOBLOCKS); 234 } 231 LONG ordinal = 0; 232 APIRET rc = xDosGetInfoBlocks(&ptib, &ppib); 233 234 if (rc) 235 ordinal = 0; 235 236 else 236 237 ordinal = ptib->tib_ptib2->tib2_ultid; … … 238 239 return ordinal; 239 240 } 240 241 #endif // FORTIFY242 241 243 242 VOID SetShiftState(VOID) … … 522 521 hasAccessDT = TRUE; 523 522 if (driveflags[x] & DRIVE_NOEASUPPORT) { 524 525 523 hasSubjects = FALSE; 524 hasLongNames = FALSE; 526 525 } 527 526 else { 528 529 527 hasSubjects = TRUE; 528 hasLongNames = TRUE; 530 529 } 531 530 } … … 534 533 hasAccessDT = FALSE; 535 534 if (driveflags[x] & DRIVE_NOEASUPPORT) { 536 537 535 hasSubjects = FALSE; 536 hasLongNames = FALSE; 538 537 } 539 538 else { 540 541 539 hasSubjects = TRUE; 540 hasLongNames = TRUE; 542 541 } 543 542 } … … 547 546 hasAccessDT = FALSE; 548 547 if (driveflags[x] & DRIVE_NOEASUPPORT) { 549 550 548 hasSubjects = FALSE; 549 hasLongNames = FALSE; 551 550 } 552 551 else { 553 554 552 hasSubjects = TRUE; 553 hasLongNames = TRUE; 555 554 } 556 555 } … … 585 584 GetPString(IDS_CRTIME), 586 585 pds->detailscrtime ? hasCreateDT : FALSE, 587 586 FALSE); 588 587 if (pds->detailslongname && !pds->detailssubject && hasSubjects) { 589 588 AdjustCnrColVis(hwndCnr, 590 589 compare ? GetPString(IDS_STATUS) : GetPString(IDS_SUBJ), 591 590 TRUE, 592 591 FALSE); 593 592 AdjustCnrColVis(hwndCnr, 594 595 596 593 GetPString(IDS_LNAME), 594 pds->detailslongname ? hasLongNames : FALSE, 595 FALSE); 597 596 WinSendMsg(hwndCnr, CM_INVALIDATEDETAILFIELDINFO, MPVOID, MPVOID); 598 597 } 599 598 else 600 599 AdjustCnrColVis(hwndCnr, 601 602 603 600 GetPString(IDS_LNAME), 601 pds->detailslongname ? hasLongNames : FALSE, 602 FALSE); 604 603 AdjustCnrColVis(hwndCnr, 605 606 607 604 compare ? GetPString(IDS_STATUS) : GetPString(IDS_SUBJ), 605 pds->detailssubject ? hasSubjects : FALSE, 606 FALSE); 608 607 WinSendMsg(hwndCnr, CM_INVALIDATEDETAILFIELDINFO, MPVOID, MPVOID); 609 608 } … … 621 620 if (!directory) { 622 621 AdjustCnrColVis(hwndCnr, 623 624 625 622 compare ? GetPString(IDS_STATUS) : GetPString(IDS_SUBJ), 623 pds->detailssubject, 624 FALSE); 626 625 AdjustCnrColVis(hwndCnr, GetPString(IDS_LADATE), pds->detailsladate, FALSE); 627 626 AdjustCnrColVis(hwndCnr, GetPString(IDS_LATIME), pds->detailslatime, FALSE); … … 693 692 if (!dsDirCnrDefault.fSubjectInLeftPane) 694 693 pfiLastLeftCol = pfi; 695 else 694 else 696 695 pfiLastLeftCol = pfi->pNextFieldInfo; 697 696 … … 703 702 pfi->flTitle = CFA_LEFT | CFA_FITITLEREADONLY; 704 703 pfi->pTitleData = isCompCnr ? (PSZ)GetPString(IDS_STATUS) : 705 704 (PSZ)GetPString(IDS_SUBJ); 706 705 pfi->offStruct = FIELDOFFSET(CNRITEM, pszSubject); 707 706 pfi->cxWidth = dsDirCnrDefault.SubjectDisplayWidth; … … 884 883 xfree(psz, pszSrcFile, __LINE__); 885 884 } 886 887 888 889 890 891 892 893 894 895 885 else { 886 psz = xrealloc(pci->pszSubject, retlen + 1, pszSrcFile, __LINE__); 887 if (psz) 888 pci->pszSubject = psz; 889 else { 890 xfree(pci->pszSubject, pszSrcFile, __LINE__); 891 pci->pszSubject = NullStr; 892 return FALSE; // out of memory 893 } 894 } 896 895 } 897 896 else { … … 949 948 xfree(psz, pszSrcFile, __LINE__); 950 949 } 951 952 953 954 955 956 957 958 959 960 950 else { 951 psz = xrealloc(pci->pszLongName, retlen + 1, pszSrcFile, __LINE__); 952 if (psz) 953 pci->pszLongName = psz; 954 else { 955 xfree(pci->pszLongName, pszSrcFile, __LINE__); 956 pci->pszLongName = NullStr; 957 return FALSE; // out of memory 958 } 959 } 961 960 } 962 961 else { … … 967 966 return (MRESULT) WriteLongName(pci->pszFileName, longname); 968 967 } 969 970 971 968 else { 969 WinQueryWindowText(hwndMLE, sizeof(testname), testname); 970 // fixme to check for other illegal chars? GKY 11 Jul 15 972 971 if (strchr(testname, '?') || strchr(testname, '*')) 973 972 return (MRESULT) FALSE; … … 977 976 if (!IsFullName(testname)) 978 977 Runtime_Error(pszSrcFile, __LINE__, "bad name"); 979 978 else { 980 979 if (DosQueryPathInfo(testname, //Why does this return 0 when the file doesn't exist? 981 980 FIL_QUERYFULLNAME, // No new directory creation? … … 985 984 FIL_QUERYFULLNAME, 986 985 oldname, sizeof(oldname))) 987 986 strcpy(oldname, pci->pszFileName); 988 987 WinSetWindowText(hwndMLE, oldname); 989 if (strcmp(oldname, newname)) { 990 991 992 DosBeep(50, 100); 988 if (strcmp(oldname, newname)) { 989 if (stricmp(oldname, newname) && IsFile(newname) != -1) { 990 if (!fAlertBeepOff) 991 DosBeep(50, 100); 993 992 return (MRESULT) FALSE; // exists; disallow 994 993 } … … 1000 999 if (docopyf(MOVE, oldname, newname)) 1001 1000 Runtime_Error(pszSrcFile, __LINE__, "docopyf"); 1002 1003 1001 else { 1002 fPostName = TRUE; 1004 1003 } 1005 1004 if (fResetVerify) { … … 1020 1019 1021 1020 if (fPostName) { 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1021 CHAR *filename; 1022 DIRCNRDATA *dcd; 1023 1024 if (!dcd) 1025 dcd = INSTDATA(hwnd); 1026 filename = xstrdup(oldname, pszSrcFile, __LINE__); 1027 if (filename) { 1028 if (!PostMsg(hwnd,UM_FIXEDITNAME, MPVOID, MPFROMP(filename))) 1029 free(filename); 1030 } 1031 if (strcmp(newname, NullStr)) { 1032 filename = xstrdup(newname, pszSrcFile, __LINE__); 1033 if (filename) { 1034 if (!PostMsg(hwnd, UM_FIXEDITNAME, MPVOID, MPFROMP(filename))) 1035 free(filename); 1036 } 1037 } 1038 fPostName = FALSE; 1040 1039 } 1041 1040 if (pci && (INT) pci != -1 && !IsRoot(pci->pszFileName)) { … … 1352 1351 while (info) { 1353 1352 WinSendMsg(mit.hwndSubMenu, MM_DELETEITEM, 1354 1353 MPFROMSHORT((SHORT) (info->ID)), MPVOID); 1355 1354 x++; 1356 1355 info = info->next; … … 1358 1357 while (numitems != MIT_ERROR) { // Delete items that were deleted from commands since the ID is gone 1359 1358 numitems = (SHORT) WinSendMsg(mit.hwndSubMenu, MM_ITEMIDFROMPOSITION, 1360 1359 MPFROMSHORT((SHORT) 1), MPVOID); 1361 1360 WinSendMsg(mit.hwndSubMenu, MM_DELETEITEM, 1362 1361 MPFROMSHORT(numitems), MPVOID); 1363 1362 } 1364 1363 if (hwndCnr && cmdhead) { … … 1367 1366 while (info) { 1368 1367 1369 1368 CHAR s[CCHMAXPATH + 24]; 1370 1369 1371 1370 sprintf(s, 1372 1371 "%s {%i} %s%s%s", 1373 1372 info->title, info->ID, 1374 1373 info->HotKeyID && info->HotKeyID < IDM_COMMANDNUM20 ? "\tCtrl + " : NullStr, 1375 1376 1377 1378 1374 info->HotKeyID && info->HotKeyID > IDM_COMMANDNUM19 ? "\tAlt + " : NullStr, 1375 info->HotKeyID && ((info->HotKeyID > IDM_COMMANDNUM9 && 1376 info->HotKeyID < IDM_COMMANDNUM20) || 1377 info->HotKeyID > IDM_COMMANDNUM29) ? "Shift + " : NullStr); 1379 1378 if (info->HotKeyID) 1380 1379 sprintf(&s[strlen(s)], "%d", 1381 1382 1383 mi.id = (USHORT) info->ID; 1380 (((info->HotKeyID - IDM_COMMANDNUM0) % 10) + 1) == 10 ? 0 : 1381 ((info->HotKeyID - IDM_COMMANDNUM0) % 10) + 1); 1382 mi.id = (USHORT) info->ID; 1384 1383 mi.afAttribute = (info->flags & ONCE ? MIA_CHECKED : 0) | 1385 1384 (info->flags & PROMPT ? MIA_FRAMED : 0); … … 1473 1472 PrfQueryProfileData(fmprof, appname, s, (PVOID) &pds->SubjectDisplayWidth, &size); 1474 1473 if (pds->SubjectDisplayWidth < 50) 1475 1474 pds->SubjectDisplayWidth = 0; 1476 1475 else if (pds->SubjectDisplayWidth > 1000) 1477 1476 pds->SubjectDisplayWidth = 1000; 1478 1477 } 1479 1478 } … … 1706 1705 1707 1706 for (;;) { 1708 pmi = (PMINIRECORDCORE) WinSendMsg(hwndCnr, CM_QUERYRECORDEMPHASIS, 1707 pmi = (PMINIRECORDCORE) WinSendMsg(hwndCnr, 1708 CM_QUERYRECORDEMPHASIS, 1709 1709 MPFROMLONG(CMA_FIRST), 1710 1710 MPFROMSHORT(attrib)); 1711 if ((!pmi || (INT) pmi == -1) && attrib == CRA_SELECTED) // punt1712 attrib = CRA_CURSORED; 1711 if ((!pmi || (INT)pmi == -1) && attrib == CRA_SELECTED) 1712 attrib = CRA_CURSORED; // Retry cursored 1713 1713 else 1714 break; 1715 } 1716 return ( (INT)pmi == -1)? NULL : pmi;1714 break; // punt 1715 } 1716 return (INT)pmi == -1 ? NULL : pmi; 1717 1717 } 1718 1718 … … 2036 2036 fDefaultDeletePerm ? IDM_PERMDELETE : IDM_DELETE); 2037 2037 SetConditionalCascade(CollectorFileMenu, IDM_OPENSUBMENU, 2038 2038 IDM_OPENDEFAULT); 2039 2039 SetConditionalCascade(CollectorFileMenu, IDM_OPENSUBCNRMENU, 2040 2040 IDM_OPENWINDOW); -
trunk/dll/misc.h
r1444 r1840 7 7 8 8 Copyright (c) 1993-98 M. Kimes 9 Copyright (c) 2008, 20 09Steven H. Levine9 Copyright (c) 2008, 2015 Steven H. Levine 10 10 11 11 17 Jul 08 SHL Baseline … … 13 13 22 Jul 09 GKY Check if drives support EAs add driveflag for this 14 14 22 Jul 09 GKY Allow .LONGNAME to be displayed for FAT drives. 15 09 Aug 15 SHL Expose GetTidForThread 15 16 16 17 ***********************************************************************/ … … 25 26 #include "dircnrs.h" // typedef for DETAILS_SETTINGS 26 27 28 UINT GetTidForThread(VOID); 29 27 30 #ifdef FORTIFY 28 INT GetTidForThread(VOID); 29 INT GetTidForWindow(HWND hwnd); 31 UINT GetTidForWindow(HWND hwnd); 30 32 #endif 31 33
Note:
See TracChangeset
for help on using the changeset viewer.