From: Bruno H. <br...@cl...> - 2017-03-08 23:10:41
|
Hi Sam, > What's the status of these functions? asciz_equal and asciz_length are the usual functions to use on C strings. > Are they officially obsolete? No. > ISTR that strlen and strmp were avoided because they used registers that > CLISP reserved for itself - it this still the case? I avoided strlen and strcmp because * As you say, we cannot expect that libc functions respect our choices of reserved CPU registers. Thus the need to wrap calls of strlen and strcmp between begin_system_call() / end_system_call(). * I also like the naming because "asciz" is just one data type among many others, and we have a function named asciz_to_string. In other words, the C and POSIX standards have terrible naming conventions. (Could you tell me, without looking it up, what is the difference between memcpy, mempcpy, and memccpy?) > When can I use strncmp(3)? (we don't have a replacement) strncmp is very easily used in the wrong way. (I guess I do it wrong 1 out of 2 times.) I prefer APIs that are maybe less general, but have a semantics that is easier to grasp, such as boolean asciz_startswith (const char* s, const char* prefix) or /* If s starts with the prefix, return the portion of s after the prefix, otherwise return NULL. */ const char* asciz_tail (const char* s, const char* prefix) Bruno |