X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/226d3997c4e356a1935b7d51b310034b4833afb9..d0c5cc5a4f87a98928093830eab689dcdd0dd603:/src/xbt/xbt_str.c diff --git a/src/xbt/xbt_str.c b/src/xbt/xbt_str.c index 25ba37ac2f..a8d06e7bc1 100644 --- a/src/xbt/xbt_str.c +++ b/src/xbt/xbt_str.c @@ -18,12 +18,12 @@ * 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. - * - "\n" (ASCII 10 (0x0A)) line feed. - * - "\r" (ASCII 13 (0x0D)) carriage return. - * - "\0" (ASCII 0 (0x00)) NULL. - * - "\x0B" (ASCII 11 (0x0B)) vertical tab. + * - " " (ASCII 32 (0x20)) space. + * - "\t" (ASCII 9 (0x09)) tab. + * - "\n" (ASCII 10 (0x0A)) line feed. + * - "\r" (ASCII 13 (0x0D)) carriage return. + * - "\0" (ASCII 0 (0x00)) NULL. + * - "\x0B" (ASCII 11 (0x0B)) vertical tab. * * @param s The string to strip. Modified in place. * @param char_list A string which contains the characters you want to strip. @@ -62,12 +62,12 @@ void xbt_str_rtrim(char *s, const char *char_list) * 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. - * - "\n" (ASCII 10 (0x0A)) line feed. - * - "\r" (ASCII 13 (0x0D)) carriage return. - * - "\0" (ASCII 0 (0x00)) NULL. - * - "\x0B" (ASCII 11 (0x0B)) vertical tab. + * - " " (ASCII 32 (0x20)) space. + * - "\t" (ASCII 9 (0x09)) tab. + * - "\n" (ASCII 10 (0x0A)) line feed. + * - "\r" (ASCII 13 (0x0D)) carriage return. + * - "\0" (ASCII 0 (0x00)) NULL. + * - "\x0B" (ASCII 11 (0x0B)) vertical tab. * * @param s The string to strip. Modified in place. * @param char_list A string which contains the characters you want to strip. @@ -103,12 +103,12 @@ void xbt_str_ltrim(char *s, const char *char_list) * 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. - * - "\n" (ASCII 10 (0x0A)) line feed. - * - "\r" (ASCII 13 (0x0D)) carriage return. - * - "\0" (ASCII 0 (0x00)) NULL. - * - "\x0B" (ASCII 11 (0x0B)) vertical tab. + * - " " (ASCII 32 (0x20)) space. + * - "\t" (ASCII 9 (0x09)) tab. + * - "\n" (ASCII 10 (0x0A)) line feed. + * - "\r" (ASCII 13 (0x0D)) carriage return. + * - "\0" (ASCII 0 (0x00)) NULL. + * - "\x0B" (ASCII 11 (0x0B)) vertical tab. * * @param s The string to strip. * @param char_list A string which contains the characters you want to strip. @@ -223,12 +223,12 @@ char *xbt_str_varsubst(const char *str, xbt_dict_t patterns) * * By default (with sep=NULL), these characters are used as separator: * - * - " " (ASCII 32 (0x20)) space. - * - "\t" (ASCII 9 (0x09)) tab. - * - "\n" (ASCII 10 (0x0A)) line feed. - * - "\r" (ASCII 13 (0x0D)) carriage return. - * - "\0" (ASCII 0 (0x00)) NULL. - * - "\x0B" (ASCII 11 (0x0B)) vertical tab. + * - " " (ASCII 32 (0x20)) space. + * - "\t" (ASCII 9 (0x09)) tab. + * - "\n" (ASCII 10 (0x0A)) line feed. + * - "\r" (ASCII 13 (0x0D)) carriage return. + * - "\0" (ASCII 0 (0x00)) NULL. + * - "\x0B" (ASCII 11 (0x0B)) vertical tab. */ xbt_dynar_t xbt_str_split(const char *s, const char *sep) @@ -574,9 +574,11 @@ long getline(char **buf, size_t * n, FILE * stream) /* * Diff related functions * - * Implementation of the algorithm described in "An O(NP) Sequence - * Comparison Algorithm", by Sun Wu, Udi Manber, Gene Myers, and Webb - * Miller. + * Implementation of the algorithm described in "An O(NP) Sequence Comparison + * Algorithm", by Sun Wu, Udi Manber, Gene Myers, and Webb Miller (Information + * Processing Letters 35(6):317-323, 1990), with the linear-space + * divide-and-conquer strategy described in "An O(ND) Difference Algorithm and + * Its Variations", by Eugene W. Myers (Algorithmica 1:251-266, 1986). */ struct subsequence { @@ -901,6 +903,28 @@ char *xbt_str_from_file(FILE * file) return res; } +/* @brief Retrun 1 if string 'str' starts with string 'start' + * + * \param str a string + * \param start the string to search in str + * + * \return 1 if 'str' starts with 'start' + */ +int xbt_str_start_with(const char* str, const char* start) +{ + int i; + size_t l_str = strlen(str); + size_t l_start = strlen(start); + + if(l_start > l_str) return 0; + + for(i = 0; i< l_start; i++){ + if(str[i] != start[i]) return 0; + } + + return 1; +} + #ifdef SIMGRID_TEST #include "xbt/str.h"