MCPcopy Create free account
hub / github.com/acl-dev/acl / path_str_strip

Function path_str_strip

lib_acl/src/stdlib/string/acl_mystring.c:286–318  ·  view source on GitHub ↗

-------------------------------------------------------------------------- * ����ָ��ĵ�ǰλ��, ����ɾ��·���ж���� '/'(for unix) or '\\'(for windows) * ���ҷ��صĵ�ǰָ�����洢���ַ�Ϊ '\0', �������ڶ����ַ��п���Ϊ '/' or '\\', * Ҳ�п��ܲ�Ϊ //'/' or '\\', ���ڽ�����о�������������� '/' or '\\' */

Source from the content-addressed store, hash-verified

284 * Ҳ�п��ܲ�Ϊ //'/' or '\\', ���ڽ�����о�������������� '/' or '\\'
285 */
286static char *path_str_strip(const char *psrc, char *pbuf, int sizeb)
287{
288 const char *ptr = psrc;
289 char *obj;
290 int n;
291
292 if (ptr == NULL || *ptr == 0 || pbuf == NULL || sizeb <= 0) {
293 return NULL;
294 }
295
296 obj = pbuf;
297 n = sizeb;
298
299 while (*ptr && n > 0) {
300 /* skip any useless '/'(in unix) or '\\'(in windows) */
301 if (*ptr == PATH_SEP_C && *(ptr + 1) == PATH_SEP_C) {
302 /* Nothing */
303 } else {
304 *obj++ = *ptr;
305 n--;
306 }
307
308 ptr++;
309 }
310
311 if (n <= 0) { /* ˵�������Ļ������ռ䲻���� */
312 return NULL;
313 }
314
315 /* ���뱣֤���һ���ַ����� '\0' ���� */
316 *obj = 0;
317 return obj;
318}
319/*----------------------------------------------------------------------------
320 * ��֤���������������ʽ:
321 * /home/avwall/test.txt

Callers 2

acl_file_path_correctFunction · 0.85
acl_dir_correctFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…