Changeset 121 for trunk/src


Ignore:
Timestamp:
Dec 5, 2001, 9:37:33 PM (24 years ago)
Author:
umoeller
Message:

Misc changes.

Location:
trunk/src/helpers
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/helpers/debug.c

    r68 r121  
    15821582                    {
    15831583                        // 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);
    15851588                        /* fprintf(LogFile, "(ppLineDef: 0x%lX) ",
    15861589                                    LINEDEFOFFSET(SegDef)
     
    15971600                    {
    15981601                        // 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);
    16011607                        fprintf(LogFile, "\n");
    16021608                        break;
     
    16101616                    if (SymDef16.wSymVal > TrapOffset)
    16111617                    {
    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);
    16151622                    }
    16161623                    LastVal = SymDef16.wSymVal;
     
    16201627                    if (SymDef16.wSymVal > TrapOffset)
    16211628                    {
    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);
    16261634                        break;
    16271635                    }
  • trunk/src/helpers/dosh.c

    r116 r121  
    16771677 +      +-------------------------+------+-----------+-----------+
    16781678 *
     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 *
    16791687 *      *ppFile receives a new XFILE structure describing
    16801688 *      the open file, if NO_ERROR is returned.
     
    16841692
    16851693APIRET doshOpen(PCSZ pcszFilename,   // in: filename to open
    1686                 ULONG ulOpenMode,       // in: XOPEN_* mode
     1694                ULONG flOpenMode,       // in: XOPEN_* mode
    16871695                PULONG pcbFile,         // in: new file size (if new file is created)
    16881696                                        // out: file size
     
    16961704                          | OPEN_FLAGS_NOINHERIT;
    16971705
    1698     switch (ulOpenMode)
     1706    switch (flOpenMode & XOPEN_ACCESS_MASK)
    16991707    {
    17001708        case XOPEN_READ_EXISTING:
     
    17031711            fsOpenMode |=   OPEN_SHARE_DENYWRITE
    17041712                          | OPEN_ACCESS_READONLY;
     1713            // _Pmpf((__FUNCTION__ ": opening XOPEN_READ_EXISTING"));
    17051714        break;
    17061715
     
    17101719            fsOpenMode |=   OPEN_SHARE_DENYREADWRITE
    17111720                          | OPEN_ACCESS_READWRITE;
     1721            // _Pmpf((__FUNCTION__ ": opening XOPEN_READWRITE_APPEND"));
    17121722        break;
    17131723
     
    17171727            fsOpenMode |=   OPEN_SHARE_DENYREADWRITE
    17181728                          | OPEN_ACCESS_READWRITE;
     1729            // _Pmpf((__FUNCTION__ ": opening XOPEN_READWRITE_NEW"));
    17191730        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)
    17231737    {
    17241738        PXFILE pFile;
     
    17281742
    17291743            ZERO(pFile);
     1744
     1745            // copy open flags
     1746            pFile->flOpenMode = flOpenMode;
    17301747
    17311748            if (!(arc = DosOpen((PSZ)pcszFilename,
     
    17411758
    17421759                if (    (ulAction == FILE_EXISTED)
    1743                      && (ulOpenMode == XOPEN_READWRITE_APPEND)
     1760                     && ((flOpenMode & XOPEN_ACCESS_MASK) == XOPEN_READWRITE_APPEND)
    17441761                   )
    17451762                    // get its size and set ptr to end for append
     
    18141831 *      to find out the length.
    18151832 *
     1833 *      If the file is not in binary mode, all
     1834 *      \n chars are converted to \r\n before
     1835 *      writing.
     1836 *
    18161837 *@@added V0.9.16 (2001-10-19) [umoeller]
     1838 *@@changed V0.9.16 (2001-12-02) [umoeller]: added XOPEN_BINARY \r\n support
    18171839 */
    18181840
     
    18211843                 ULONG cb)
    18221844{
    1823     APIRET arc;
     1845    APIRET arc = NO_ERROR;
    18241846    if (!pcsz)
    18251847        arc = ERROR_INVALID_PARAMETER;
     
    18321854            arc = ERROR_INVALID_PARAMETER;
    18331855        else
    1834             if (!(arc = doshLockFile(pFile)))   // this checks for pFile
     1856        {
     1857            PSZ pszNew = NULL;
     1858
     1859            if (!(pFile->flOpenMode & XOPEN_BINARY))
    18351860            {
    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                }
    18441900            }
     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        }
    18451920    }
    18461921
     
    18541929 *
    18551930 *      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.
    18581932 */
    18591933
     
    18831957            va_end(arg_ptr);
    18841958
    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';
    18861962            szTemp[ulLength++] = '\n';
    18871963
  • trunk/src/helpers/except.c

    r119 r121  
    673673
    674674        if (G_pfnExcHook)
    675         {
    676             (*G_pfnExcHook)(file, ptib);
    677         }
     675            G_pfnExcHook(file, ptib, ulOldPriority);  // V0.9.16 (2001-12-02) [pr]
    678676
    679677        // *** registers
  • trunk/src/helpers/nls.c

    r116 r121  
    325325 *
    326326 *@@added V0.9.0 (99-11-07) [umoeller]
     327 *@@changed V0.9.16 (2001-12-05) [pr]: fixed AM/PM hour bug
    327328 */
    328329
     
    341342            case 0:  // mm.dd.yyyy  (English)
    342343                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);
    348349            break;
    349350
    350351            case 1:  // dd.mm.yyyy  (e.g. German)
    351352                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);
    357358            break;
    358359
    359360            case 2: // yyyy.mm.dd  (Japanese)
    360361                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);
    366367            break;
    367368
    368369            default: // yyyy.dd.mm
    369370                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);
    375376            break;
    376377        }
     
    384385            CHAR szAMPM[10] = "err";
    385386
    386             if (pDateTime->hours > 12)
     387            if (pDateTime->hours >= 12)  // V0.9.16 (2001-12-05) [pr] if (pDateTime->hours > 12)
    387388            {
    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.
    394390                PrfQueryProfileString(HINI_USER,
    395                     "PM_National",
    396                     "s2359",        // key
    397                     "PM",           // default
    398                     szAMPM, sizeof(szAMPM)-1);
     391                                      "PM_National",
     392                                      "s2359",        // key
     393                                      "PM",           // default
     394                                      szAMPM, sizeof(szAMPM)-1);
    399395                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);
    407403            }
    408404            else
    409405            {
    410                 // <= 12h: AM
     406                // < 12h: AM
    411407                PrfQueryProfileString(HINI_USER,
    412408                                      "PM_National",
     
    415411                                      szAMPM, sizeof(szAMPM)-1);
    416412                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);
    423419            }
    424420        }
     
    426422            // 24-hour clock
    427423            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);
    433429    }
    434430}
  • trunk/src/helpers/xml.c

    r117 r121  
    276276        case ERROR_DOM_ATTLIST_DECL_OUTSIDE_DOCTYPE:
    277277            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");
    278284    }
    279285
     
    15501556                                                                papcszAttribs[i + 1],  // attr value
    15511557                                                                &pAttrib)))
     1558                    {
    15521559                        // shall we validate?
    15531560                        if (pDom->pDocTypeNode)
     
    15551562                                                  pAttrib,
    15561563                                                  &pAttribDeclBase);
     1564                    }
    15571565                    else
    15581566                    {
     
    15601568                                    pDom->arcDOM,
    15611569                                    papcszAttribs[i],
    1562                                     TRUE);      // validation
     1570                                    FALSE);      // validation
    15631571                        break;
    15641572                    }
  • trunk/src/helpers/xstring.c

    r111 r121  
    8585
    8686/*
    87  *      Copyright (C) 1999-2000 Ulrich M”ller.
     87 *      Copyright (C) 1999-2001 Ulrich M”ller.
    8888 *      This file is part of the "XWorkplace helpers" source package.
    8989 *      This is free software; you can redistribute it and/or modify
     
    220220{
    221221    if (!pszNew)
    222     {
    223222        memset(pxstr, 0, sizeof(XSTRING));
    224     }
    225223    else
    226224    {
     
    792790 +          //                             1         2
    793791 +
    794  +          xstrInitCopy(&xstrReplacement, "stupid");
    795  +
    796792 +          xstrrpl(&xstr,
    797793 +                  10,     // position of "test"
    798794 +                  4,      // length of "test"
    799  +                  &xstrReplacement);
     795 +                  "stupid",
     796 +                  6);     // strlen("stupid")
    800797 *
    801798 *      This would yield "This is a stupid string."
     
    878875            {
    879876                // 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
    888880                // V0.9.11 (2001-04-22) [umoeller]
    889 
    890881                memcpy(pszNew + ulFirstReplOfs,
    891882                       pcszReplaceWith,
Note: See TracChangeset for help on using the changeset viewer.