IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 7380 for trunk/psLib/src/sys


Ignore:
Timestamp:
Jun 6, 2006, 5:22:07 PM (20 years ago)
Author:
Paul Price
Message:

Merging the pslib "additional" functions from the modules into psLib proper.

Added jpeg directory for psImageJpeg.
Changes to build system (configure.ac, and various Makefile.am)

psVectorSmooth: changed API to allow optional output vector
psSparse: changed sizes to type "long"; added "const"
psRegionIsBad: Renamed psRegionIsNaN
psImageBicubeFit: changed sizes to "long"; added a "const"
psLine: changed sizes to "long"
psImageUnbin: description required in SDRS
psImageClippedStats: renaming to psImageBackground; removing static structures; API changed!
psImageFlipX, psImageFlipY merged to psImageFlip
psStringSubstitute: added "const"

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

Legend:

Unmodified
Added
Removed
  • trunk/psLib/src/sys/Makefile.am

    r7210 r7380  
    99        psError.c      \
    1010        psErrorCodes.c \
     11        psLine.c       \
    1112        psLogMsg.c     \
    1213        psMemory.c     \
     
    3233        psError.h      \
    3334        psErrorCodes.h \
     35        psLine.h       \
    3436        psLogMsg.h     \
    3537        psMemory.h     \
  • trunk/psLib/src/sys/psString.c

    r7251 r7380  
    1313 *  @author David Robbins, MHPCC
    1414 *
    15  *  @version $Revision: 1.30 $ $Name: not supported by cvs2svn $
    16  *  @date $Date: 2006-05-31 20:56:37 $
     15 *  @version $Revision: 1.31 $ $Name: not supported by cvs2svn $
     16 *  @date $Date: 2006-06-07 03:22:06 $
    1717 *
    1818 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    3131psString psStringCopy(const char *string)
    3232{
    33     PS_ASSERT_PTR_NON_NULL(string, NULL);
     33    // Pass through NULL values!
     34
    3435    // Allocate memory using psAlloc function
    3536    // Copy input string to memory just allocated
    3637    // Return the copy
    37     // Pass through NULL values
    3838    return string ? strcpy(psAlloc(strlen(string) + 1), string) : NULL;
    3939}
     
    218218// given the input string, search for all copies of the key, and replace with the replacement value
    219219// the input string may be freed if not needed
    220 char *psStringSubstitute (char *input, char *replace, char *key)
    221 {
    222 
    223     char *p;
    224 
    225     if (key == NULL)
     220char *psStringSubstitute(char *input, const char *replace, const char *key)
     221{
     222    if (key == NULL || strlen(key) == 0) {
    226223        return input;
    227     if (strlen(key) == 0)
    228         return input;
     224    }
    229225
    230226    while (true) {
    231         p = strstr (input, key);
    232         if (p == NULL)
     227        char *p = strstr (input, key);
     228        if (!p) {
    233229            return input;
     230        }
    234231
    235232        // we have input = xxxkeyxxx
     
    241238
    242239        // copy the first segement into 'output'
    243         strncpy (output, input, Nc);
     240        strncpy(output, input, Nc);
    244241
    245242        // copy the key replacement to the start of the key
    246 
    247         strcpy (&output[Nc], replace);
     243        strcpy(&output[Nc], replace);
    248244        Nc += strlen (replace);
    249245
    250246        // copy the remainder to the end of the replacement
    251         strcpy (&output[Nc], p + strlen(key));
    252 
    253         psFree (input);
     247        strcpy(&output[Nc], p + strlen(key));
     248
     249        psFree(input);
    254250        input = output;
    255251    }
     
    257253}
    258254
     255psArray *psStringSplitArray(const char *string, const char *splitters, bool multi)
     256{
     257
     258    psList *list = psStringSplit(string, splitters, multi);
     259    psArray *array = psListToArray(list);
     260    psFree (list);
     261    return array;
     262}
     263
     264#ifndef whitespace
     265#define whitespace(c) (((c) == ' ') || ((c) == '\t'))
     266#endif
     267
     268/* Strip whitespace from the start and end of STRING. */
     269size_t psStringStrip(char *string)
     270{
     271    long i;
     272
     273    if (!string || strlen(string) == 0) {
     274        return 0;
     275    }
     276
     277    for (i = 0; i < strlen(string) && whitespace(string[i]); i++)
     278        ; // No action
     279    if (i) {
     280        memmove (string, string + i, strlen(string+i)+1);
     281    }
     282    for (i = strlen (string) - 1; (i > 0) && whitespace(string[i]); i--)
     283        ; // No action
     284    string[++i] = 0;
     285
     286    return i;
     287}
  • trunk/psLib/src/sys/psString.h

    r7300 r7380  
    1414 *  @author David Robbins, MHPCC
    1515 *
    16  *  @version $Revision: 1.21 $ $Name: not supported by cvs2svn $
    17  *  @date $Date: 2006-06-02 21:33:34 $
     16 *  @version $Revision: 1.22 $ $Name: not supported by cvs2svn $
     17 *  @date $Date: 2006-06-07 03:22:06 $
    1818 *
    1919 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    107107);
    108108
    109 // given the input string, search for all copies of the key, and replace with the replacement value
     109// Same as psStringSplit, but return result as an array
     110psArray *psStringSplitArray(const char *string, // String to split
     111                            const char *splitters, // Characters on which to split
     112                            bool multipleAreSignificant // Are multiple occurences significant?
     113                           );
     114
     115// Given the input string, search for all copies of the key, and replace with the replacement value
    110116// the input string may be freed if not needed
    111 char *psStringSubstitute (
    112     char *input,    ///< input string to be modified
    113     char *replace,    ///< replacement value
    114     char *key    ///< string to be replaced in input
    115 );
     117char *psStringSubstitute (char *input,  ///< input string to be modified
     118                          const char *replace, ///< replacement value
     119                          const char *key ///< string to be replaced in input
     120                         );
     121
     122// strip whitespace from head and tail of string
     123size_t psStringStrip(char *string);
     124
    116125
    117126/** @} */// Doxygen - End of SystemGroup Functions
Note: See TracChangeset for help on using the changeset viewer.