IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
May 31, 2006, 10:56:37 AM (20 years ago)
Author:
Paul Price
Message:

Removing commented-out code (old version of psStringSplit).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psLib/src/sys/psString.c

    r7115 r7251  
    1313 *  @author David Robbins, MHPCC
    1414 *
    15  *  @version $Revision: 1.29 $ $Name: not supported by cvs2svn $
    16  *  @date $Date: 2006-05-13 08:56:48 $
     15 *  @version $Revision: 1.30 $ $Name: not supported by cvs2svn $
     16 *  @date $Date: 2006-05-31 20:56:37 $
    1717 *
    1818 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    173173}
    174174
    175 # if 0
    176 // XXX: This should probably be implemented using strpbrk
    177 // XXX : add a boolean "repeats significant"
    178 // XXX : NULL input string returns empty (not NULL) list
    179 // XXX : NULL splitters is an error
    180 psList *psStringSplit(const char *string,
    181                       const char *splitters)
    182 {
    183     PS_ASSERT_PTR_NON_NULL(splitters, NULL);
    184 
    185     psList *values = psListAlloc(NULL); // The list of values to return
    186     PS_ASSERT_PTR_NON_NULL(string, values);
    187 
    188     unsigned int length = strlen(string); // The length of the string
    189     unsigned int numSplitters = strlen(splitters); // Number of characters that might split
    190     unsigned int start = 0;             // The position of the start of a word
    191     for (int i = 1; i < length; i++) {
    192         bool split = false;             // Is this character a splitter?
    193         for (int j = 0; j < numSplitters && ! split; j++) {
    194             if (string[i] == splitters[j]) {
    195                 split = true;
    196             }
    197         }
    198         if (split) {
    199             if (i == start) {
    200                 // Some idiot put in two spaces, or two commas or something
    201                 start++;
    202             } else {
    203                 // We're at the end of the word
    204                 psString word = psStringNCopy(&string[start], i - start);
    205                 (void)psListAdd(values, PS_LIST_TAIL, word);
    206                 start = i + 1;
    207                 psFree(word);
    208             }
    209         }
    210     }
    211     if (start < length) {
    212         // Copy the last word
    213         psString word = psStringNCopy(&string[start], length - start);
    214         (void)psListAdd(values, PS_LIST_TAIL, word);
    215         psFree(word);
    216     }
    217 
    218     return values;
    219 }
    220 # endif
    221 
    222175// split the string by the given splitters
    223176// NULL input string returns empty (not NULL) list
     
    230183
    231184    psList *values = psListAlloc(NULL); // The list of values to return
    232     if (string == NULL)
     185    // An input NULL string should not generate an error: it is a valid case
     186    if (string == NULL) {
    233187        return values;
    234     // XXX this should not generate an error : it is a valid case
    235     // PS_ASSERT_PTR_NON_NULL(string, values);
     188    }
    236189
    237190    char *next = NULL;
Note: See TracChangeset for help on using the changeset viewer.