- Timestamp:
- Dec 5, 2001, 9:37:33 PM (24 years ago)
- Location:
- trunk/src/helpers
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/helpers/debug.c
r68 r121 1582 1582 { 1583 1583 // symbol found 1584 fprintf(LogFile, "between %s + 0x%lX ", Buffer, TrapOffset - LastVal); 1584 fprintf(LogFile, 1585 "between %s + 0x%lX ", 1586 Buffer, 1587 TrapOffset - LastVal); 1585 1588 /* fprintf(LogFile, "(ppLineDef: 0x%lX) ", 1586 1589 LINEDEFOFFSET(SegDef) … … 1597 1600 { 1598 1601 // symbol found, as above 1599 fprintf(LogFile, " " 1600 "and %s - 0x%lX ", Buffer, LastVal - TrapOffset); 1602 fprintf(LogFile, 1603 " " 1604 "and %s - 0x%lX ", 1605 Buffer, 1606 LastVal - TrapOffset); 1601 1607 fprintf(LogFile, "\n"); 1602 1608 break; … … 1610 1616 if (SymDef16.wSymVal > TrapOffset) 1611 1617 { 1612 fprintf(LogFile, "between %s + %lX\n", 1613 Buffer, 1614 TrapOffset - LastVal); 1618 fprintf(LogFile, 1619 "between %s + %lX\n", 1620 Buffer, 1621 TrapOffset - LastVal); 1615 1622 } 1616 1623 LastVal = SymDef16.wSymVal; … … 1620 1627 if (SymDef16.wSymVal > TrapOffset) 1621 1628 { 1622 fprintf(LogFile, " " 1623 "and %s - %lX\n", 1624 Buffer, 1625 LastVal - TrapOffset); 1629 fprintf(LogFile, 1630 " " 1631 "and %s - %lX\n", 1632 Buffer, 1633 LastVal - TrapOffset); 1626 1634 break; 1627 1635 } -
trunk/src/helpers/dosh.c
r116 r121 1677 1677 + +-------------------------+------+-----------+-----------+ 1678 1678 * 1679 * In addition, you can specify the XOPEN_BINARY flag: 1680 * 1681 * -- If XOPEN_BINARY is set, no conversion is performed 1682 * on read and write. 1683 * 1684 * -- If XOPEN_BINARY is _not_ set, all \n chars are 1685 * converted to \r\n on write. 1686 * 1679 1687 * *ppFile receives a new XFILE structure describing 1680 1688 * the open file, if NO_ERROR is returned. … … 1684 1692 1685 1693 APIRET doshOpen(PCSZ pcszFilename, // in: filename to open 1686 ULONG ulOpenMode, // in: XOPEN_* mode1694 ULONG flOpenMode, // in: XOPEN_* mode 1687 1695 PULONG pcbFile, // in: new file size (if new file is created) 1688 1696 // out: file size … … 1696 1704 | OPEN_FLAGS_NOINHERIT; 1697 1705 1698 switch ( ulOpenMode)1706 switch (flOpenMode & XOPEN_ACCESS_MASK) 1699 1707 { 1700 1708 case XOPEN_READ_EXISTING: … … 1703 1711 fsOpenMode |= OPEN_SHARE_DENYWRITE 1704 1712 | OPEN_ACCESS_READONLY; 1713 // _Pmpf((__FUNCTION__ ": opening XOPEN_READ_EXISTING")); 1705 1714 break; 1706 1715 … … 1710 1719 fsOpenMode |= OPEN_SHARE_DENYREADWRITE 1711 1720 | OPEN_ACCESS_READWRITE; 1721 // _Pmpf((__FUNCTION__ ": opening XOPEN_READWRITE_APPEND")); 1712 1722 break; 1713 1723 … … 1717 1727 fsOpenMode |= OPEN_SHARE_DENYREADWRITE 1718 1728 | OPEN_ACCESS_READWRITE; 1729 // _Pmpf((__FUNCTION__ ": opening XOPEN_READWRITE_NEW")); 1719 1730 break; 1720 } 1721 1722 if (pcszFilename && fsOpenFlags && pcbFile && ppFile) 1731 1732 default: 1733 arc = ERROR_INVALID_PARAMETER; 1734 } 1735 1736 if ((!arc) && pcszFilename && fsOpenFlags && pcbFile && ppFile) 1723 1737 { 1724 1738 PXFILE pFile; … … 1728 1742 1729 1743 ZERO(pFile); 1744 1745 // copy open flags 1746 pFile->flOpenMode = flOpenMode; 1730 1747 1731 1748 if (!(arc = DosOpen((PSZ)pcszFilename, … … 1741 1758 1742 1759 if ( (ulAction == FILE_EXISTED) 1743 && ( ulOpenMode== XOPEN_READWRITE_APPEND)1760 && ((flOpenMode & XOPEN_ACCESS_MASK) == XOPEN_READWRITE_APPEND) 1744 1761 ) 1745 1762 // get its size and set ptr to end for append … … 1814 1831 * to find out the length. 1815 1832 * 1833 * If the file is not in binary mode, all 1834 * \n chars are converted to \r\n before 1835 * writing. 1836 * 1816 1837 *@@added V0.9.16 (2001-10-19) [umoeller] 1838 *@@changed V0.9.16 (2001-12-02) [umoeller]: added XOPEN_BINARY \r\n support 1817 1839 */ 1818 1840 … … 1821 1843 ULONG cb) 1822 1844 { 1823 APIRET arc ;1845 APIRET arc = NO_ERROR; 1824 1846 if (!pcsz) 1825 1847 arc = ERROR_INVALID_PARAMETER; … … 1832 1854 arc = ERROR_INVALID_PARAMETER; 1833 1855 else 1834 if (!(arc = doshLockFile(pFile))) // this checks for pFile 1856 { 1857 PSZ pszNew = NULL; 1858 1859 if (!(pFile->flOpenMode & XOPEN_BINARY)) 1835 1860 { 1836 ULONG cbWritten; 1837 if (!(arc = DosWrite(pFile->hf, 1838 (PSZ)pcsz, 1839 cb, 1840 &cbWritten))) 1841 pFile->cbCurrent += cbWritten; 1842 1843 doshUnlockFile(pFile); 1861 // convert all \n to \r\n: 1862 // V0.9.16 (2001-12-02) [umoeller] 1863 1864 // count all \n first 1865 ULONG cNewLines = 0; 1866 PCSZ pSource = pcsz; 1867 ULONG ul; 1868 for (ul = 0; 1869 ul < cb; 1870 ul++) 1871 { 1872 if (*pSource++ == '\n') 1873 cNewLines++; 1874 } 1875 1876 if (cNewLines) 1877 { 1878 // we have '\n' chars: 1879 // then we need just as many \r chars inserted 1880 ULONG cbNew = cb + cNewLines; 1881 if (!(pszNew = (PSZ)malloc(cbNew))) 1882 arc = ERROR_NOT_ENOUGH_MEMORY; 1883 else 1884 { 1885 PSZ pTarget = pszNew; 1886 pSource = pcsz; 1887 for (ul = 0; 1888 ul < cb; 1889 ul++) 1890 { 1891 CHAR c = *pSource++; 1892 if (c == '\n') 1893 *pTarget++ = '\r'; 1894 *pTarget++ = c; 1895 } 1896 1897 cb = cbNew; 1898 } 1899 } 1844 1900 } 1901 1902 if (!arc) 1903 if (!(arc = doshLockFile(pFile))) // this checks for pFile 1904 { 1905 ULONG cbWritten; 1906 if (!(arc = DosWrite(pFile->hf, 1907 (pszNew) 1908 ? pszNew 1909 : (PSZ)pcsz, 1910 cb, 1911 &cbWritten))) 1912 pFile->cbCurrent += cbWritten; 1913 1914 doshUnlockFile(pFile); 1915 } 1916 1917 if (pszNew) 1918 free(pszNew); 1919 } 1845 1920 } 1846 1921 … … 1854 1929 * 1855 1930 * The internal string buffer is limited to 2000 1856 * characters. \n is NOT translated to \r\n before 1857 * writing. 1931 * characters. Length checking is _not_ performed. 1858 1932 */ 1859 1933 … … 1883 1957 va_end(arg_ptr); 1884 1958 1885 szTemp[ulLength++] = '\r'; 1959 if (pFile->flOpenMode & XOPEN_BINARY) 1960 // if we're in binary mode, we need to add \r too 1961 szTemp[ulLength++] = '\r'; 1886 1962 szTemp[ulLength++] = '\n'; 1887 1963 -
trunk/src/helpers/except.c
r119 r121 673 673 674 674 if (G_pfnExcHook) 675 { 676 (*G_pfnExcHook)(file, ptib); 677 } 675 G_pfnExcHook(file, ptib, ulOldPriority); // V0.9.16 (2001-12-02) [pr] 678 676 679 677 // *** registers -
trunk/src/helpers/nls.c
r116 r121 325 325 * 326 326 *@@added V0.9.0 (99-11-07) [umoeller] 327 *@@changed V0.9.16 (2001-12-05) [pr]: fixed AM/PM hour bug 327 328 */ 328 329 … … 341 342 case 0: // mm.dd.yyyy (English) 342 343 sprintf(pszDate, "%02d%c%02d%c%04d", 343 pDateTime->month,344 cDateSep,345 pDateTime->day,346 cDateSep,347 pDateTime->year);344 pDateTime->month, 345 cDateSep, 346 pDateTime->day, 347 cDateSep, 348 pDateTime->year); 348 349 break; 349 350 350 351 case 1: // dd.mm.yyyy (e.g. German) 351 352 sprintf(pszDate, "%02d%c%02d%c%04d", 352 pDateTime->day,353 cDateSep,354 pDateTime->month,355 cDateSep,356 pDateTime->year);353 pDateTime->day, 354 cDateSep, 355 pDateTime->month, 356 cDateSep, 357 pDateTime->year); 357 358 break; 358 359 359 360 case 2: // yyyy.mm.dd (Japanese) 360 361 sprintf(pszDate, "%04d%c%02d%c%02d", 361 pDateTime->year,362 cDateSep,363 pDateTime->month,364 cDateSep,365 pDateTime->day);362 pDateTime->year, 363 cDateSep, 364 pDateTime->month, 365 cDateSep, 366 pDateTime->day); 366 367 break; 367 368 368 369 default: // yyyy.dd.mm 369 370 sprintf(pszDate, "%04d%c%02d%c%02d", 370 pDateTime->year,371 cDateSep,372 pDateTime->day,373 cDateSep,374 pDateTime->month);371 pDateTime->year, 372 cDateSep, 373 pDateTime->day, 374 cDateSep, 375 pDateTime->month); 375 376 break; 376 377 } … … 384 385 CHAR szAMPM[10] = "err"; 385 386 386 if (pDateTime->hours > 12)387 if (pDateTime->hours >= 12) // V0.9.16 (2001-12-05) [pr] if (pDateTime->hours > 12) 387 388 { 388 // > 12h: PM. 389 390 // Note: 12:xx noon is 12 AM, not PM (even though 391 // AM stands for "ante meridiam", but English is just 392 // not logical), so that's handled below. 393 389 // >= 12h: PM. 394 390 PrfQueryProfileString(HINI_USER, 395 "PM_National",396 "s2359", // key397 "PM", // default398 szAMPM, sizeof(szAMPM)-1);391 "PM_National", 392 "s2359", // key 393 "PM", // default 394 szAMPM, sizeof(szAMPM)-1); 399 395 sprintf(pszTime, "%02d%c%02d%c%02d %s", 400 // leave 12 == 12 (not 0)401 pDateTime->hours % 12,402 cTimeSep,403 pDateTime->minutes,404 cTimeSep,405 pDateTime->seconds,406 szAMPM);396 // leave 12 == 12 (not 0) 397 pDateTime->hours % 12, 398 cTimeSep, 399 pDateTime->minutes, 400 cTimeSep, 401 pDateTime->seconds, 402 szAMPM); 407 403 } 408 404 else 409 405 { 410 // < =12h: AM406 // < 12h: AM 411 407 PrfQueryProfileString(HINI_USER, 412 408 "PM_National", … … 415 411 szAMPM, sizeof(szAMPM)-1); 416 412 sprintf(pszTime, "%02d%c%02d%c%02d %s", 417 pDateTime->hours,418 cTimeSep,419 pDateTime->minutes,420 cTimeSep,421 pDateTime->seconds,422 szAMPM);413 pDateTime->hours, 414 cTimeSep, 415 pDateTime->minutes, 416 cTimeSep, 417 pDateTime->seconds, 418 szAMPM); 423 419 } 424 420 } … … 426 422 // 24-hour clock 427 423 sprintf(pszTime, "%02d%c%02d%c%02d", 428 pDateTime->hours,429 cTimeSep,430 pDateTime->minutes,431 cTimeSep,432 pDateTime->seconds);424 pDateTime->hours, 425 cTimeSep, 426 pDateTime->minutes, 427 cTimeSep, 428 pDateTime->seconds); 433 429 } 434 430 } -
trunk/src/helpers/xml.c
r117 r121 276 276 case ERROR_DOM_ATTLIST_DECL_OUTSIDE_DOCTYPE: 277 277 return ("Attlist declaration outside doctype"); 278 279 case ERROR_DOM_INCOMPLETE_ENCODING_MAP: 280 return ("Incomplete encoding map specified"); 281 282 case ERROR_DOM_INVALID_EXTERNAL_HANDLER: 283 return ("Invalid 'external' handler specified"); 278 284 } 279 285 … … 1550 1556 papcszAttribs[i + 1], // attr value 1551 1557 &pAttrib))) 1558 { 1552 1559 // shall we validate? 1553 1560 if (pDom->pDocTypeNode) … … 1555 1562 pAttrib, 1556 1563 &pAttribDeclBase); 1564 } 1557 1565 else 1558 1566 { … … 1560 1568 pDom->arcDOM, 1561 1569 papcszAttribs[i], 1562 TRUE); // validation1570 FALSE); // validation 1563 1571 break; 1564 1572 } -
trunk/src/helpers/xstring.c
r111 r121 85 85 86 86 /* 87 * Copyright (C) 1999-200 0Ulrich Mller.87 * Copyright (C) 1999-2001 Ulrich Mller. 88 88 * This file is part of the "XWorkplace helpers" source package. 89 89 * This is free software; you can redistribute it and/or modify … … 220 220 { 221 221 if (!pszNew) 222 {223 222 memset(pxstr, 0, sizeof(XSTRING)); 224 }225 223 else 226 224 { … … 792 790 + // 1 2 793 791 + 794 + xstrInitCopy(&xstrReplacement, "stupid");795 +796 792 + xstrrpl(&xstr, 797 793 + 10, // position of "test" 798 794 + 4, // length of "test" 799 + &xstrReplacement); 795 + "stupid", 796 + 6); // strlen("stupid") 800 797 * 801 798 * This would yield "This is a stupid string." … … 878 875 { 879 876 // we have a replacement: 880 // insert it next 881 882 /* memcpy(pszNew + ulFirstReplOfs, 883 pstrReplaceWith->psz, 884 cReplaceWithLen + 1); // include null terminator 885 */ 886 // no, we no longer can be sure that pcszReplaceWith is 887 // null terminated, so terminate explicitly 877 // insert it next... 878 // we no longer can be sure that pcszReplaceWith 879 // is null terminated, so terminate explicitly 888 880 // V0.9.11 (2001-04-22) [umoeller] 889 890 881 memcpy(pszNew + ulFirstReplOfs, 891 882 pcszReplaceWith,
Note:
See TracChangeset
for help on using the changeset viewer.