Changeset 194


Ignore:
Timestamp:
Jul 28, 2002, 11:48:47 AM (23 years ago)
Author:
umoeller
Message:

Misc fixes.

Location:
trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/helpers/dosh.h

    r190 r194  
    903903                       PCSZ pcszName);
    904904
     905    BOOL doshMatchCaseNoPath(const char *pcszMask,
     906                             const char *pcszName);
     907
    905908    BOOL doshMatch(PCSZ pcszMask,
    906909                   PCSZ pcszName);
  • trunk/include/helpers/nls.h

    r184 r194  
    129129        typedef NLSDATETIME *PNLSDATETIME;
    130130
    131         APIRET XWPENTRY nlsUpper(PSZ psz, ULONG ulLength);
     131        ULONG nlsUpper(PSZ psz);
    132132
    133133    #endif
  • trunk/src/helpers/dosh2.c

    r170 r194  
    20462046
    20472047                // skip extra asterisks
     2048                /*
    20482049                do
    20492050                {
    20502051                    ++pMask;
    20512052                } while (*pMask == '*');
     2053                */
     2054
     2055                while (*(++pMask) == '*')       // V0.9.20 (2002-07-25) [umoeller]
     2056                    ;
    20522057
    20532058                // pMask points to after '*';
     
    20892094
    20902095/*
    2091  *@@ doshMatch:
     2096 *@@ doshMatchCase:
    20922097 *      this matches '*' and '?' wildcards, similar to what
    2093  *      DosEditName does. It returns TRUE if the given name
    2094  *      matches the given mask.
    2095  *
    2096  *      However, this does not require a file to be present, but
    2097  *      works on strings only.
     2098 *      DosEditName does. However, this does not require a
     2099 *      file to be present, but works on strings only.
     2100 *
     2101 *      Returns TRUE if the given name matches the given mask.
    20982102 *
    20992103 *      This accepts both short and fully qualified masks and
     
    21062110 *          wildcards.
    21072111 *
    2108  *      --  This compares without respect to case always.
     2112 *      --  This compares WITH respect to case always. Upper-case
     2113 *          both the mask and the name before calling this, or
     2114 *          use doshMatch instead.
    21092115 *
    21102116 *      --  As opposed to the WPS, this handles multiple dots in
     
    21132119 *          one will.
    21142120 *
    2115  *      --  THIS COMPARES WITH RESPECT TO CASE.
    2116  *
    21172121 *      This replaces strhMatchOS2 which has been removed with
    21182122 *      V0.9.16 and is a lot faster than the old code, which has
     
    21272131    BOOL    brc = FALSE;
    21282132
    2129     int     iMaskDrive = -1,
    2130             iNameDrive = -1;
    2131 
    21322133    PCSZ    pLastMaskComponent,
    21332134            pLastNameComponent;
     
    21352136    ULONG   cbMaskPath = 0,
    21362137            cbNamePath = 0;
    2137 
    2138     CHAR    c;
    21392138
    21402139    if (pLastMaskComponent = strrchr(pcszMask, '\\'))
     
    21762175
    21772176/*
     2177 *@@ doshMatchCaseNoPath:
     2178 *      like doshMatchCase, but is faster if you are sure that
     2179 *      neither pcszMask nor pcszName contain path separators
     2180 *      ("\" characters). In other words, this is for short
     2181 *      filenames.
     2182 *
     2183 *@@added V0.9.20 (2002-07-25) [umoeller]
     2184 */
     2185
     2186BOOL doshMatchCaseNoPath(const char *pcszMask,     // in: mask (e.g. "*.TXT")
     2187                         const char *pcszName)     // in: string to check (e.g. "TEST.TXT")
     2188{
     2189    return PerformMatch(pcszMask,
     2190                        pcszName,
     2191                        // has dot?
     2192                        (strchr(pcszName, '.') != NULL));
     2193}
     2194
     2195/*
    21782196 *@@ doshMatch:
    21792197 *      like doshMatchCase, but compares without respect
     
    21922210
    21932211    memcpy(pszMask, pcszMask, cbMask + 1);
    2194     nlsUpper(pszMask, cbMask);
     2212    nlsUpper(pszMask);
    21952213    memcpy(pszName, pcszName, cbName + 1);
    2196     nlsUpper(pszName, cbName);
    2197 
    2198     return (doshMatchCase(pszMask,
    2199                           pszName));
    2200 }
     2214    nlsUpper(pszName);
     2215
     2216    return doshMatchCase(pszMask,
     2217                         pszName);
     2218}
  • trunk/src/helpers/nls.c

    r190 r194  
    752752}
    753753
     754CHAR G_szUpperMap[257];
     755BOOL G_fUpperMapInited = FALSE;
     756
     757/*
     758 *@@ InitUpperMap:
     759 *      initializes the case map for nlsUpper.
     760 *
     761 *@@added V0.9.20 (2002-07-25) [umoeller]
     762 */
     763
     764static VOID InitUpperMap(VOID)
     765{
     766    ULONG ul;
     767    COUNTRYCODE cc;
     768    BOOL fDBCS = nlsDBCS();
     769
     770    for (ul = 0;
     771         ul < sizeof(G_szUpperMap);
     772         ++ul)
     773    {
     774        G_szUpperMap[ul] = (CHAR)ul;
     775
     776        if (    (fDBCS)
     777             && (G_afLeadByte[ul] != TYPE_SBCS)
     778           )
     779            G_szUpperMap[ul] = ' ';
     780    }
     781
     782    G_szUpperMap[256] = '\0';
     783
     784    cc.country = 0;         // use system country code
     785    cc.codepage = 0;        // use process default codepage
     786    DosMapCase(255,
     787               &cc,
     788               G_szUpperMap + 1);
     789
     790    G_fUpperMapInited = TRUE;
     791}
    754792
    755793/*
     
    757795 *      quick hack for upper-casing a string.
    758796 *
    759  *      This uses DosMapCase with the default system country
    760  *      code and the process's codepage. WARNING: DosMapCase
    761  *      is a 16-bit API and therefore quite slow. Use this
    762  *      with care.
     797 *      This now returns the length of the given string always
     798 *      (V0.9.20).
     799 *
     800 *      Remarks:
     801 *
     802 *      --  On the first call, we build a case map table by
     803 *          calling DosMapCase with the default system country
     804 *          code and the process's codepage. Since DosMapCase
     805 *          is terribly slow with all the 16-bit thunking
     806 *          involved, we can then use our table without having
     807 *          to use the API ever again.
     808 *
     809 *      --  As a result, if the process codepage changes for
     810 *          any reason, this function will not pick up the
     811 *          change.
     812 *
     813 *      --  This has provisions for DBCS, which hopefully
     814 *          work.
    763815 *
    764816 *@@added V0.9.16 (2001-10-25) [umoeller]
    765  */
    766 
    767 APIRET nlsUpper(PSZ psz,            // in/out: string
    768                 ULONG ulLength)     // in: string length; if 0, we run strlen(psz)
    769 {
    770     COUNTRYCODE cc;
     817 *@@changed V0.9.20 (2002-07-25) [umoeller]: speedup, changed prototype
     818 */
     819
     820ULONG nlsUpper(PSZ psz)            // in/out: string
     821{
     822    ULONG   ul = 0;
     823
     824    if (!G_fUpperMapInited)
     825        InitUpperMap();
    771826
    772827    if (psz)
    773828    {
    774         if (!ulLength)
    775             ulLength = strlen(psz);
    776 
    777         if (ulLength)
    778         {
    779             cc.country = 0;         // use system country code
    780             cc.codepage = 0;        // use process default codepage
    781             return DosMapCase(ulLength,
    782                               &cc,
    783                               psz);
    784         }
    785     }
    786 
    787     return ERROR_INVALID_PARAMETER;
    788 }
    789 
    790 
     829        PSZ     p = psz;
     830
     831        while (*p++ = G_szUpperMap[*p])
     832            ++ul;
     833    }
     834
     835    return ul;
     836}
     837
     838
  • trunk/src/helpers/prfh.c

    r167 r194  
    189189 */
    190190
    191 PSZ (prfhQueryProfileData)(HINI hIni,      // in: INI handle (can be HINI_USER or HINI_SYSTEM)
    192                          const char *pcszApp,     // in: application to query
    193                          const char *pcszKey,     // in: key to query
    194                          PULONG pcbBuf)  // out: size of the returned buffer; ptr can be NULL
     191PSZ (prfhQueryProfileData)(HINI hIni,           // in: INI handle (can be HINI_USER or HINI_SYSTEM)
     192                         const char *pcszApp,   // in: application to query
     193                         const char *pcszKey,   // in: key to query
     194                         PULONG pcbBuf)         // out: size of the returned buffer; ptr can be NULL
    195195{
    196196    PSZ     pData = NULL;
    197     ULONG   ulSizeOfData = 0;
     197    ULONG   ulSizeOfData;
    198198
    199199    // get size of data for pszApp/pszKey
    200     if (PrfQueryProfileSize(hIni, (PSZ)pcszApp, (PSZ)pcszKey, &ulSizeOfData))
    201     {
    202         if (ulSizeOfData)
    203         {
    204             pData = (PSZ)malloc(ulSizeOfData);
    205             if (!PrfQueryProfileData(hIni, (PSZ)pcszApp, (PSZ)pcszKey, pData, &ulSizeOfData))
    206             {
    207                 free(pData);
    208                 pData = NULL;
    209             }
     200    if (    (PrfQueryProfileSize(hIni, (PSZ)pcszApp, (PSZ)pcszKey, &ulSizeOfData))
     201         && (ulSizeOfData)
     202         && (pData = (PSZ)malloc(ulSizeOfData))
     203       )
     204    {
     205        if (!PrfQueryProfileData(hIni, (PSZ)pcszApp, (PSZ)pcszKey, pData, &ulSizeOfData))
     206        {
     207            free(pData);
     208            pData = NULL;
    210209        }
    211210    }
  • trunk/src/helpers/vcard.c

    r167 r194  
    365365
    366366                *pNextColon = '\0';
    367                 nlsUpper(pLineThis,
    368                          pNextColon - pLineThis);
     367                nlsUpper(pLineThis);
    369368
    370369                if (pNextSemicolon = strchr(pLineThis, ';'))
Note: See TracChangeset for help on using the changeset viewer.