git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@3501
48e7efb5-ca39-0410-a469-
dd3cf9ba447f
#endif
/* Trim related functions */
#endif
/* Trim related functions */
-XBT_PUBLIC(char*) xbt_str_rtrim(char* s, const char* char_list);
-XBT_PUBLIC(char*) xbt_str_ltrim( char* s, const char* char_list);
-XBT_PUBLIC(char*) xbt_str_trim(char* s, const char* char_list);
+XBT_PUBLIC(void) xbt_str_rtrim(char* s, const char* char_list);
+XBT_PUBLIC(void) xbt_str_ltrim( char* s, const char* char_list);
+XBT_PUBLIC(void) xbt_str_trim(char* s, const char* char_list);
XBT_PUBLIC(xbt_dynar_t) xbt_str_split(char *s, const char *sep);
XBT_PUBLIC(char *) xbt_str_join(xbt_dynar_t dynar, const char *sep);
XBT_PUBLIC(xbt_dynar_t) xbt_str_split(char *s, const char *sep);
XBT_PUBLIC(char *) xbt_str_join(xbt_dynar_t dynar, const char *sep);
/** @brief Strip whitespace (or other characters) from the end of a string.
*
/** @brief Strip whitespace (or other characters) from the end of a string.
*
- * This function returns a string with whitespace stripped from the end of s.
- * By default (without the second parameter char_list), xbt_str_rtrim() will strip these characters :
+ * Strips the whitespaces from the end of s.
+ * By default (when char_list=NULL), these characters get stripped:
*
* - " " (ASCII 32 (0x20)) space.
* - "\t" (ASCII 9 (0x09)) tab.
*
* - " " (ASCII 32 (0x20)) space.
* - "\t" (ASCII 9 (0x09)) tab.
* - "\0" (ASCII 0 (0x00)) NULL.
* - "\x0B" (ASCII 11 (0x0B)) vertical tab.
*
* - "\0" (ASCII 0 (0x00)) NULL.
* - "\x0B" (ASCII 11 (0x0B)) vertical tab.
*
- * @param s The string to strip.
+ * @param s The string to strip. Modified in place.
* @param char_list A string which contains the characters you want to strip.
*
* @param char_list A string which contains the characters you want to strip.
*
- * @return If the specified is NULL the function returns NULL. Otherwise the
- * function returns the string with whitespace stripped from the end.
xbt_str_rtrim(char* s, const char* char_list)
{
char* cur = s;
xbt_str_rtrim(char* s, const char* char_list)
{
char* cur = s;
char white_char[256] = {1,0};
if(!s)
char white_char[256] = {1,0};
if(!s)
if(!char_list){
while(*__char_list) {
if(!char_list){
while(*__char_list) {
}
/** @brief Strip whitespace (or other characters) from the beginning of a string.
*
}
/** @brief Strip whitespace (or other characters) from the beginning of a string.
*
- * This function returns a string with whitespace stripped from the beginning of s.
- * By default (without the second parameter char_list), xbt_str_ltrim() will strip these characters :
+ * Strips the whitespaces from the begining of s.
+ * By default (when char_list=NULL), these characters get stripped:
*
* - " " (ASCII 32 (0x20)) space.
* - "\t" (ASCII 9 (0x09)) tab.
*
* - " " (ASCII 32 (0x20)) space.
* - "\t" (ASCII 9 (0x09)) tab.
* - "\0" (ASCII 0 (0x00)) NULL.
* - "\x0B" (ASCII 11 (0x0B)) vertical tab.
*
* - "\0" (ASCII 0 (0x00)) NULL.
* - "\x0B" (ASCII 11 (0x0B)) vertical tab.
*
- * @param s The string to strip.
+ * @param s The string to strip. Modified in place.
* @param char_list A string which contains the characters you want to strip.
*
* @param char_list A string which contains the characters you want to strip.
*
- * @return If the specified is NULL the function returns NULL. Otherwise the
- * function returns the string with whitespace stripped from the beginning.
xbt_str_ltrim( char* s, const char* char_list)
{
char* cur = s;
xbt_str_ltrim( char* s, const char* char_list)
{
char* cur = s;
char white_char[256] = {1,0};
if(!s)
char white_char[256] = {1,0};
if(!s)
if(!char_list){
while(*__char_list) {
if(!char_list){
while(*__char_list) {
while(*cur && white_char[(unsigned char)*cur])
++cur;
while(*cur && white_char[(unsigned char)*cur])
++cur;
- return memmove(s,cur, strlen(cur));
+ memmove(s,cur, strlen(cur));
}
/** @brief Strip whitespace (or other characters) from the end and the begining of a string.
*
}
/** @brief Strip whitespace (or other characters) from the end and the begining of a string.
*
- * This returns a string with whitespace stripped from the end and the begining of s.
- * By default (without the second parameter char_list), xbt_str_trim() will strip these characters :
+ * Strips the whitespaces from both the beginning and the end of s.
+ * By default (when char_list=NULL), these characters get stripped:
*
* - " " (ASCII 32 (0x20)) space.
* - "\t" (ASCII 9 (0x09)) tab.
*
* - " " (ASCII 32 (0x20)) space.
* - "\t" (ASCII 9 (0x09)) tab.
* @param s The string to strip.
* @param char_list A string which contains the characters you want to strip.
*
* @param s The string to strip.
* @param char_list A string which contains the characters you want to strip.
*
- * @return If the specified is NULL the function returns NULL. Otherwise the
- * function returns the string with whitespace stripped from the end and the begining.
xbt_str_trim(char* s, const char* char_list ){
if(!s)
xbt_str_trim(char* s, const char* char_list ){
if(!s)
- return xbt_str_ltrim(xbt_str_rtrim(s,char_list),char_list);
+ xbt_str_rtrim(s,char_list);
+ xbt_str_ltrim(s,char_list);
}
/** @brief Replace double whitespaces (but no other characters) from the string.
}
/** @brief Replace double whitespaces (but no other characters) from the string.