Changeset 6874 for trunk/psLib/src/sys
- Timestamp:
- Apr 17, 2006, 12:00:35 PM (20 years ago)
- Location:
- trunk/psLib/src/sys
- Files:
-
- 3 edited
-
psString.c (modified) (2 diffs)
-
psString.h (modified) (2 diffs)
-
psType.h (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/src/sys/psString.c
r6278 r6874 13 13 * @author David Robbins, MHPCC 14 14 * 15 * @version $Revision: 1.2 4$ $Name: not supported by cvs2svn $16 * @date $Date: 2006-0 2-01 20:40:56$15 * @version $Revision: 1.25 $ $Name: not supported by cvs2svn $ 16 * @date $Date: 2006-04-17 22:00:03 $ 17 17 * 18 18 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 214 214 } 215 215 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 218 char *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 14 14 * @author David Robbins, MHPCC 15 15 * 16 * @version $Revision: 1.1 8$ $Name: not supported by cvs2svn $17 * @date $Date: 2006-0 2-01 20:40:56$16 * @version $Revision: 1.19 $ $Name: not supported by cvs2svn $ 17 * @date $Date: 2006-04-17 22:00:03 $ 18 18 * 19 19 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 103 103 ); 104 104 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 107 char *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 105 113 /** @} */// Doxygen - End of SystemGroup Functions 106 114 -
trunk/psLib/src/sys/psType.h
r6349 r6874 10 10 * @author Ross Harman, MHPCC 11 11 * 12 * @version $Revision: 1.4 6$ $Name: not supported by cvs2svn $13 * @date $Date: 2006-0 2-08 00:00:35$12 * @version $Revision: 1.47 $ $Name: not supported by cvs2svn $ 13 * @date $Date: 2006-04-17 22:00:03 $ 14 14 * 15 15 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 130 130 PS_DATA_POLYNOMIAL4D, ///< psPolynomial4D 131 131 PS_DATA_PROJECTION, ///< psProjection 132 PS_DATA_REGION, ///< psRegion 132 133 PS_DATA_SCALAR, ///< psScalar 133 134 PS_DATA_SPHERE, ///< psSphere
Note:
See TracChangeset
for help on using the changeset viewer.
