[PATCH] string: add GNU basename(3)

Mike Frysinger vapier@gentoo.org
Fri Mar 13 16:48:00 GMT 2015


On 13 Mar 2015 11:25, Yaakov Selkowitz wrote:
> +char* 

pretty sure newlib follows GNU style which means this code needs a bit of work

space before the * here

> +	if( path == NULL || *path == '\0' )

spacing is wrong:
	if (path == NULL || *path == '\0')

> +	p = (char *)path + strlen(path) - 1;

i would mark p const and delay the cast to the return

space for func calls though:
	... + strlen (path) ...

> +	if( *p == '/' )

bad spacing

> +	while( p >= path && *p != '/' )

bad spacing

> +		p--;
> +	return p + 1;

there should be a newline before the return
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://sourceware.org/pipermail/newlib/attachments/20150313/6ccea0e8/attachment.sig>


More information about the Newlib mailing list