[Toybox] A couple of minor fixes

Paul Barker paul at paulbarker.me.uk
Mon Jun 13 08:49:46 PDT 2016


On Mon, 13 Jun 2016 16:13:19 +0100
Paul Barker <paul at paulbarker.me.uk> wrote:
> 
> I still agree that this should be fixed in glibc if possible though.
> I'll build a test app later and see what happens for different trim
> values (INT_MAX, INT_MAX/2, INT_MAX/4, etc) with glibc in an
> OpenEmbedded build.
> 

	#include <limits.h>
	#include <stdio.h>

	int main(int argc, char *argv[])
	{
	    const char *str = "Hello, World!";
	    int trim[] = { INT_MAX, INT_MAX/2, INT_MAX/4,
		    INT_MAX/8, INT_MAX/16, INT_MAX/32, INT_MAX/64,
		    INT_MAX/128, INT_MAX/256, INT_MAX/512 };
	    int i;

	    for (i = 0; i < 10; i++) {
        	printf("trim=%d : ", trim[i]);
	        printf("%.*s", trim[i], str);
        	printf("\n");
	    }

	    return 0;
	}

Results in:

	trim=2147483647 :
	trim=1073741823 :
	trim=536870911 :
	trim=268435455 :
	trim=134217727 : Hello, World!
	trim=67108863 : Hello, World!
	trim=33554431 : Hello, World!
	trim=16777215 : Hello, World!
	trim=8388607 : Hello, World!
	trim=4194303 : Hello, World!

Thanks,
Paul Barker


More information about the Toybox mailing list