IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 6874 for trunk/psLib/src/sys


Ignore:
Timestamp:
Apr 17, 2006, 12:00:35 PM (20 years ago)
Author:
magnier
Message:

variety of small changes related to inconsistencies between psModules and psLib

Location:
trunk/psLib/src/sys
Files:
3 edited

Legend:

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

    r6278 r6874  
    1313 *  @author David Robbins, MHPCC
    1414 *
    15  *  @version $Revision: 1.24 $ $Name: not supported by cvs2svn $
    16  *  @date $Date: 2006-02-01 20:40:56 $
     15 *  @version $Revision: 1.25 $ $Name: not supported by cvs2svn $
     16 *  @date $Date: 2006-04-17 22:00:03 $
    1717 *
    1818 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    214214}
    215215
     216// given the input string, search for all copies of the key, and replace with the replacement value
     217// the input string may be freed if not needed
     218char *psStringSubstitute (char *input, char *replace, char *key)
     219{
     220
     221    char *p;
     222
     223    if (key == NULL)
     224        return input;
     225    if (strlen(key) == 0)
     226        return input;
     227
     228    while (true) {
     229        p = strstr (input, key);
     230        if (p == NULL)
     231            return input;
     232
     233        // we have input = xxxkeyxxx
     234        // we want output = xxxreplacexxx
     235
     236        // this is safe since we will subtract strlen(key) elements from input
     237        char *output = psAlloc(strlen(input) + strlen(replace) + 1);
     238        int Nc = p - input;
     239
     240        // copy the first segement into 'output'
     241        strncpy (output, input, Nc);
     242
     243        // copy the key replacement to the start of the key
     244
     245        strcpy (&output[Nc], replace);
     246        Nc += strlen (replace);
     247
     248        // copy the remainder to the end of the replacement
     249        strcpy (&output[Nc], p + strlen(key));
     250
     251        psFree (input);
     252        input = output;
     253    }
     254    return input;
     255}
     256
  • trunk/psLib/src/sys/psString.h

    r6278 r6874  
    1414 *  @author David Robbins, MHPCC
    1515 *
    16  *  @version $Revision: 1.18 $ $Name: not supported by cvs2svn $
    17  *  @date $Date: 2006-02-01 20:40:56 $
     16 *  @version $Revision: 1.19 $ $Name: not supported by cvs2svn $
     17 *  @date $Date: 2006-04-17 22:00:03 $
    1818 *
    1919 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    103103);
    104104
     105// given the input string, search for all copies of the key, and replace with the replacement value
     106// the input string may be freed if not needed
     107char *psStringSubstitute (
     108    char *input,    ///< input string to be modified
     109    char *replace,    ///< replacement value
     110    char *key    ///< string to be replaced in input
     111);
     112
    105113/** @} */// Doxygen - End of SystemGroup Functions
    106114
  • trunk/psLib/src/sys/psType.h

    r6349 r6874  
    1010*  @author Ross Harman, MHPCC
    1111*
    12 *  @version $Revision: 1.46 $ $Name: not supported by cvs2svn $
    13 *  @date $Date: 2006-02-08 00:00:35 $
     12*  @version $Revision: 1.47 $ $Name: not supported by cvs2svn $
     13*  @date $Date: 2006-04-17 22:00:03 $
    1414*
    1515*  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    130130    PS_DATA_POLYNOMIAL4D,              ///< psPolynomial4D
    131131    PS_DATA_PROJECTION,                ///< psProjection
     132    PS_DATA_REGION,                    ///< psRegion
    132133    PS_DATA_SCALAR,                    ///< psScalar
    133134    PS_DATA_SPHERE,                    ///< psSphere
Note: See TracChangeset for help on using the changeset viewer.