[PATCH] don't use strptime if we can

walter harms wharms at bfs.de
Thu Feb 16 12:30:12 UTC 2006


Hi denis,
i am missing the point. why not use strptime() when it is available in 
(g)libc ? It is posix and should be present on any decent system.

If tune2e.c has a replacement why not call it my_strptime() and make it 
available in systems that does not have it ?

re,
  walter




Denis Vlasenko wrote:
> strptime() is large (at least glibc one):
> 
> --- z_sizes     Thu Feb 16 13:08:49 2006
> +++ z_sizes_1   Thu Feb 16 13:23:34 2006
> ...
> @@ -4166,6 +4163,7 @@
>  00000290 t awk_getline
>  00000291 T rtnl_talk
>  00000293 T __mpn_mul
> +0000029a t compare_keys
>  0000029c t fileAction
>  000002a0 T ether_aton_r
>  000002a8 t read_int
> @@ -4212,7 +4210,6 @@
>  000002f7 T getopt_main
>  000002f7 t transit_state_bkref
>  000002fc T __gconv_get_path
> -000002fe t compare_keys
>  000002ff t do_show
>  00000300 R _nl_C_LC_CTYPE_class
>  00000303 T __getmntent_r
> @@ -4437,7 +4434,6 @@
>  000024e9 T __strtold_internal
>  000024f5 T __strtod_internal
>  00002a40 r translit_from_tbl
> -00002a9e t strptime_internal
>  00003214 T _IO_vfwprintf
>  00003214 W vfwprintf
>  00003214 T __vfwprintf
> 
> strptime() is used in sort.c (if CONFIG_FEATURE_SORT_BIG)
> and tune2fs.c
> 
> tune2fs.c already has alternative code and we can use it.
> sort.c is harder, I just added a FIXME.
> --
> vda
> 
> 
> ------------------------------------------------------------------------
> 
> diff -urpN busybox.org/coreutils/sort.c busybox.strpt/coreutils/sort.c
> --- busybox.org/coreutils/sort.c	Thu Feb  9 11:02:56 2006
> +++ busybox.strpt/coreutils/sort.c	Thu Feb 16 13:40:33 2006
> @@ -201,12 +201,13 @@ static int compare_keys(const void *xarg
>  				int dx;
>  				char *xx,*yy;
>  
> +				/* FIXME: strptime == bloat */ 
>  				xx=strptime(x,"%b",&thyme);
>  				dx=thyme.tm_mon;
>  				yy=strptime(y,"%b",&thyme);
>  				if(!xx) retval=(!yy ? 0 : -1);
>  				else if(!yy) retval=1;
> -				else retval=(dx==thyme.tm_mon ? 0 : dx-thyme.tm_mon);
> +				else retval=dx-thyme.tm_mon;
>  				break;
>  			}
>  			/* Full floating point version of -n */
> diff -urpN busybox.org/e2fsprogs/tune2fs.c busybox.strpt/e2fsprogs/tune2fs.c
> --- busybox.org/e2fsprogs/tune2fs.c	Thu Feb  9 11:26:59 2006
> +++ busybox.strpt/e2fsprogs/tune2fs.c	Thu Feb 16 13:41:27 2006
> @@ -383,7 +383,7 @@ static time_t parse_time(char *str)
>  		return (time(0));
>  	}
>  	memset(&ts, 0, sizeof(ts));
> -#ifdef HAVE_STRPTIME
> +#ifdef HAVE_STRPTIME_BUT_GLIBC_STRPTIME_EATS_12K
>  	strptime(str, "%Y%m%d%H%M%S", &ts);
>  #else
>  	sscanf(str, "%4d%2d%2d%2d%2d%2d", &ts.tm_year, &ts.tm_mon,
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> busybox mailing list
> busybox at busybox.net
> http://busybox.net/cgi-bin/mailman/listinfo/busybox



More information about the busybox mailing list