ucx/cx/string.h

changeset 855
6740836b7a1e
parent 854
1c8401ece69e
equal deleted inserted replaced
854:1c8401ece69e 855:6740836b7a1e
149 * 149 *
150 * The argument MUST be a string (const char*) @em literal. 150 * The argument MUST be a string (const char*) @em literal.
151 * 151 *
152 * @param literal the string literal 152 * @param literal the string literal
153 */ 153 */
154 #define CX_STR(literal) (cxstring){literal, sizeof(literal) - 1} 154 #define CX_STR(literal) ((cxstring){literal, sizeof(literal) - 1})
155 155
156 #endif 156 #endif
157 157
158 158
159 /** 159 /**
877 * @return (@c cxmutstr) a duplicate of the string 877 * @return (@c cxmutstr) a duplicate of the string
878 * @see cx_strdup() 878 * @see cx_strdup()
879 * @see cx_strfree_a() 879 * @see cx_strfree_a()
880 */ 880 */
881 #define cx_strdup_a(allocator, string) \ 881 #define cx_strdup_a(allocator, string) \
882 cx_strdup_a_((allocator), cx_strcast((string))) 882 cx_strdup_a_((allocator), cx_strcast(string))
883 883
884 /** 884 /**
885 * Creates a duplicate of the specified string. 885 * Creates a duplicate of the specified string.
886 * 886 *
887 * The new string will contain a copy allocated by standard 887 * The new string will contain a copy allocated by standard
892 * @param string the string to duplicate 892 * @param string the string to duplicate
893 * @return (@c cxmutstr) a duplicate of the string 893 * @return (@c cxmutstr) a duplicate of the string
894 * @see cx_strdup_a() 894 * @see cx_strdup_a()
895 * @see cx_strfree() 895 * @see cx_strfree()
896 */ 896 */
897 #define cx_strdup(string) cx_strdup_a_(cxDefaultAllocator, string) 897 #define cx_strdup(string) cx_strdup_a(cxDefaultAllocator, string)
898 898
899 /** 899 /**
900 * Omits leading and trailing spaces. 900 * Omits leading and trailing spaces.
901 * 901 *
902 * @note the returned string references the same memory, thus you 902 * @note the returned string references the same memory, thus you
1089 * @param delim the delimiter string (must not be empty) 1089 * @param delim the delimiter string (must not be empty)
1090 * @param limit (@c size_t) the maximum number of tokens that shall be returned 1090 * @param limit (@c size_t) the maximum number of tokens that shall be returned
1091 * @return (@c CxStrtokCtx) a new string tokenization context 1091 * @return (@c CxStrtokCtx) a new string tokenization context
1092 */ 1092 */
1093 #define cx_strtok(str, delim, limit) \ 1093 #define cx_strtok(str, delim, limit) \
1094 cx_strtok_(cx_strcast((str)), cx_strcast((delim)), (limit)) 1094 cx_strtok_(cx_strcast(str), cx_strcast(delim), (limit))
1095 1095
1096 /** 1096 /**
1097 * Returns the next token. 1097 * Returns the next token.
1098 * 1098 *
1099 * The token will point to the source string. 1099 * The token will point to the source string.

mercurial