Ignore:
Timestamp:
May 22, 2001, 7:18:41 PM (24 years ago)
Author:
umoeller
Message:

misc updates

File:
1 edited

Legend:

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

    r63 r71  
    159159 *      for analyzing CONFIG.SYS settings.
    160160 *
     161 *      Remarks:
     162 *
     163 *      --  With pcszKey, you can either specify a CONFIG.SYS
     164 *          key WITH an equals sign (e.g. search for "LIBPATH=")
     165 *          or the key name only (e.g. "SET SHELL").
     166 *
     167 *          Only in the latter case, this function makes sure
     168 *          that the search key is complete; e.g. it will not
     169 *          find "SET SHELLHANDLESINC=" then.
     170 *
     171 *      --  If the line found starts with leading spaces,
     172 *          *ppStartOfLine will still receive the start of
     173 *          the line.
     174 *          For example, if you're searching for "SET PATH"
     175 *          and the PATH line is
     176 *
     177 +              "   SET PATH=C:\os2"
     178 *
     179 *          the first space in the line is written into
     180 *          *ppStartOfLine.
     181 *
    161182 *@@changed V0.9.0 [umoeller]: fixed bug in that this would also return something if only the first chars matched
    162183 *@@changed V0.9.0 [umoeller]: fixed bug which could cause character before pszSearchIn to be examined
     
    164185 *@@changed V0.9.7 (2001-01-15) [umoeller]: now checking for tabs too
    165186 *@@changed V0.9.11 (2001-04-25) [umoeller]: this never found lines which had leading spaces, fixed
     187 *@@changed V0.9.12 (2001-05-22) [umoeller]: added checks for key termination (SET SHELLHANDLESINC)
    166188 */
    167189
     
    177199    ULONG       ulKeyLength = strlen(pcszKey);
    178200
     201    BOOL        fSearchKeyContainsEquals = (strchr(pcszKey, '=') != 0);
     202
    179203    do
    180204    {
    181         p = strhistr(p, pcszKey);
    182 
    183         if (    (p)
    184              && (p >= pcszSearchIn)
    185            )
     205        // find the key
     206        // (on first loop, p is start of buffer;
     207        // on subsequent loops, p is somewhere in bufer,
     208        // if we've found the key somewhere else)
     209        if (p = strhistr(p, pcszKey))
    186210        {
    187211            // make sure the key is at the beginning of a line
     
    207231                // OK, we're at the start of a line:
    208232
    209                 // return address of key
    210                 pReturn = (PSZ)p;
    211                 // return start of line
    212                 if (ppStartOfLine)
    213                     *ppStartOfLine = (PSZ)pStartOfLine;
    214 
    215                 // test for all upper case?
    216                 if (pfIsAllUpperCase)
     233                // check the character AFTER the
     234                // key if it's a space or '=';
     235                // without this check, we'd find
     236                // SET SHELL= if caller is really
     237                // looking for SET SHELLHANDLESINC=,
     238                // but only do this check if the caller
     239                // doesn't have '=' in the search string
     240                // already
     241                // V0.9.12 (2001-05-22) [umoeller]
     242                CHAR c = *(p + ulKeyLength);
     243                if (    (fSearchKeyContainsEquals)
     244                     || (c == ' ')
     245                     || (c == '=')
     246                     || (c == '\n')
     247                     || (c == '\r')
     248                     || (c == '\t')
     249                   )
    217250                {
    218                     ULONG   ul = 0;
    219                     *pfIsAllUpperCase = TRUE;
    220 
    221                     for (ul = 0;
    222                          ul < ulKeyLength;
    223                          ul++)
     251                    // return address of key
     252                    pReturn = (PSZ)p;
     253                    // return start of line
     254                    if (ppStartOfLine)
     255                        *ppStartOfLine = (PSZ)pStartOfLine;
     256
     257                    // test for all upper case?
     258                    if (pfIsAllUpperCase)
    224259                    {
    225                         if (islower(*(p + ul)))
     260                        ULONG   ul = 0;
     261                        *pfIsAllUpperCase = TRUE;
     262
     263                        for (ul = 0;
     264                             ul < ulKeyLength;
     265                             ul++)
    226266                        {
    227                             *pfIsAllUpperCase = FALSE;
    228                             break; // for
     267                            if (islower(*(p + ul)))
     268                            {
     269                                *pfIsAllUpperCase = FALSE;
     270                                break; // for
     271                            }
    229272                        }
    230273                    }
    231                 }
    232 
    233                 break; // do
     274
     275                    break; // do
     276                } // else search next key
    234277            } // else search next key
    235278
    236             p++; // search on after this key
     279            p += ulKeyLength; // search on after this key
     280                    // now skipping ulKeyLength V0.9.12 (2001-05-22) [umoeller]
    237281        }
    238282        else
     
    475519 *
    476520 *      If the manipulation succeeded, NO_ERROR is returned
    477  *      and *ppszChanged receives a new string describing
     521 *      and pstrChanged receives a new string describing
    478522 *      what was changed. This can be:
    479523 *
     
    502546 *
    503547 *      -- This assumes that the line breaks are represented
    504  *         by \r\n items ONLY.
     548 *         by \n ONLY. If *ppszContents has \r\n line breaks,
     549 *         they must be converted to pure \n first.
    505550 */
    506551
     
    611656                                    &pStartOfLineWithKeyFound,
    612657                                    &fIsAllUpperCase);
     658                // returns beginning of line
    613659
    614660            if (!pKeyFound)
Note: See TracChangeset for help on using the changeset viewer.