src/stdlib/path.c
/*==================================================
 * chop_path -- copy path into buff, & zero-separate all dirs
 *  path:  [IN]  path list to copy
 *  dirs:  [OUT] output buffer
 * NB: dirs should be one byte larger than path
 *     ignore zero length paths
 *================================================*/
- copy path into buff, & zero-separate all dirs
path:  [IN]  path list to copy
dirs:  [OUT] output buffer
NB: dirs should be one byte larger than path
ignore zero length paths
- copy path into buff & zero - separate all dirs path : [ IN ] path list to copy dirs : [ OUT ] output buffer NB : dirs should be one byte larger than path ignore zero length paths
INT
chop_path (CNSTRING path, STRING dirs)
{
	INT ndirs;
	STRING p;
	CNSTRING q;
	char c=0;
	ndirs=0;
	p = dirs;;
	q = path;
	while ((c = *q)) {
		if (is_path_sep(c)) {
			if (p == dirs || p[-1] == 0) {
				q++;
			} else {
				*p++ = 0;
				q++;
				++ndirs;
			}
		} else {
			*p++ = *q++;
		}
	}
	if (!(p == dirs || p[-1] == 0)) {
		*p++ = 0;
		++ndirs;
	}
	*p = 0; 
	return ndirs;
}
INT chop_path ( CNSTRING path , STRING dirs ) { INT ndirs ; STRING p ; CNSTRING q ; char c = 0 ; ndirs = 0 ; p = dirs ; ; q = path ; while ( ( c = * q ) ) { if ( is_path_sep ( c ) ) { if ( p == dirs || p [ -1 ] == 0 ) { q ++ ; } else { * p ++ = 0 ; q ++ ; ++ ndirs ; } } else { * p ++ = * q ++ ; } } if ( ! ( p == dirs || p [ -1 ] == 0 ) ) { * p ++ = 0 ; ++ ndirs ; } * p = 0 ; return ndirs ; }
chop_path -- copy path into buff, & zero-separate all dirs
  path:  [IN]  path list to copy
  dirs:  [OUT] output buffer
 NB: dirs should be one byte larger than path
     ignore zero length paths
chop_path -- copy path into buff & zero - separate all dirs path : [ IN ] path list to copy dirs : [ OUT ] output buffer NB : dirs should be one byte larger than path ignore zero length paths
/* ends with extra trailing zero after last one */