IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 6989


Ignore:
Timestamp:
Apr 25, 2006, 4:19:23 PM (20 years ago)
Author:
drobbin
Message:

updated stringSplit NULL-handling (& tests)

Location:
trunk/psLib
Files:
2 edited

Legend:

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

    r6962 r6989  
    1313 *  @author David Robbins, MHPCC
    1414 *
    15  *  @version $Revision: 1.26 $ $Name: not supported by cvs2svn $
    16  *  @date $Date: 2006-04-23 01:08:34 $
     15 *  @version $Revision: 1.27 $ $Name: not supported by cvs2svn $
     16 *  @date $Date: 2006-04-26 02:19:23 $
    1717 *
    1818 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    177177                      const char *splitters)
    178178{
    179     PS_ASSERT_PTR_NON_NULL(splitters, NULL);
    180179    psList *values = psListAlloc(NULL); // The list of values to return
    181     if (string == NULL)
    182         return values;
     180    PS_ASSERT_PTR_NON_NULL(string, values);
     181    PS_ASSERT_PTR_NON_NULL(splitters, values);
     182    //    if (string == NULL)
     183    //        return values;
    183184
    184185    unsigned int length = strlen(string); // The length of the string
  • trunk/psLib/test/sys/tst_psString.c

    r6278 r6989  
    2020 *  @author  Eric Van Alst, MHPCC
    2121 *
    22  *  @version $Revision: 1.4 $  $Name: not supported by cvs2svn $
    23  *  @date  $Date: 2006-02-01 20:40:56 $
     22 *  @version $Revision: 1.5 $  $Name: not supported by cvs2svn $
     23 *  @date  $Date: 2006-04-26 02:19:23 $
    2424 *
    2525 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    456456    psLogMsg(__func__,PS_LOG_INFO,"Following should generate error message");
    457457    strList = psStringSplit(NULL, NULL);
    458     if (strList != NULL) {
     458    //    if (strList != NULL) {
     459    if ( psListLength(strList) ) {
    459460        psFree(strList);
    460461        return 1;
    461462    }
     463    psFree(strList);
     464    strList = NULL;
    462465    //Return NULL for NULL string input
    463466    psLogMsg(__func__,PS_LOG_INFO,"Following should generate error message");
    464467    strList = psStringSplit(NULL, split);
    465     if (strList != NULL) {
     468    //    if (strList != NULL) {
     469    if ( psListLength(strList) ) {
    466470        psFree(strList);
    467471        return 2;
    468472    }
     473    psFree(strList);
     474    strList = NULL;
    469475    //Return NULL for NULL splitter input
    470476    psLogMsg(__func__,PS_LOG_INFO,"Following should generate error message");
    471477    strList = psStringSplit(str, NULL);
    472     if (strList != NULL) {
     478    //    if (strList != NULL) {
     479    if ( psListLength(strList) ) {
    473480        psFree(strList);
    474481        return 3;
    475482    }
     483    psFree(strList);
     484    strList = NULL;
    476485    //Return a psList* of psStrings
    477486    strList = psStringSplit(str, split);
     
    679688    psLogMsg(__func__,PS_LOG_INFO,"Following should generate error message");
    680689    nullList = psStringSplit(nullTest, ",");
    681     if (nullList != NULL) {
     690    //    if (nullList != NULL) {
     691    if ( psListLength(nullList) ) {
    682692        psError(PS_ERR_BAD_PARAMETER_NULL, false,
    683693                "psStringSplit failed to return NULL for NULL input string.\n");
    684694        return 5;
    685695    }
     696    psFree(nullList);
     697    nullList = NULL;
    686698    //psStringSplit should return NULL for NULL input splitter
    687699    psLogMsg(__func__,PS_LOG_INFO,"Following should generate error message");
    688700    nullList = psStringSplit("Hello World", nullTest);
    689     if (nullList != NULL) {
     701    //    if (nullList != NULL) {
     702    if ( psListLength(nullList) ) {
    690703        psError(PS_ERR_BAD_PARAMETER_NULL, false,
    691704                "psStringSplit failed to return NULL for NULL input splitter.\n");
    692705        return 6;
    693706    }
    694 
    695     return 0;
    696 }
    697 
     707    psFree(nullList);
     708
     709    return 0;
     710}
     711
Note: See TracChangeset for help on using the changeset viewer.