svn commit: trunk/uClibc/libc/unistd
vda at uclibc.org
vda at uclibc.org
Tue May 20 20:32:27 UTC 2008
Author: vda
Date: 2008-05-20 13:32:27 -0700 (Tue, 20 May 2008)
New Revision: 22027
Log:
getopt: do not needlessly use static structure.
Reorder structure members and change some of them into smallints
to reduce bss and text:
text data bss dec hex filename
- 2403 12 40 2455 997 libc/unistd/getopt.o
+ 2252 12 0 2264 8d8 libc/unistd/getopt.o
Modified:
trunk/uClibc/libc/unistd/getopt.c
trunk/uClibc/libc/unistd/getopt_int.h
Changeset:
Modified: trunk/uClibc/libc/unistd/getopt.c
===================================================================
--- trunk/uClibc/libc/unistd/getopt.c 2008-05-20 20:28:35 UTC (rev 22026)
+++ trunk/uClibc/libc/unistd/getopt.c 2008-05-20 20:32:27 UTC (rev 22027)
@@ -162,10 +162,6 @@
int optopt = '?';
-/* Keep a global copy of all internal members of getopt_data. */
-
-static struct _getopt_data getopt_data;
-
#ifndef __GNU_LIBRARY__
@@ -1158,7 +1154,9 @@
const struct option *longopts, int *longind, int long_only)
{
int result;
+ struct _getopt_data getopt_data;
+ memset(&getopt_data, 0, sizeof(getopt_data));
getopt_data.optind = optind;
getopt_data.opterr = opterr;
Modified: trunk/uClibc/libc/unistd/getopt_int.h
===================================================================
--- trunk/uClibc/libc/unistd/getopt_int.h 2008-05-20 20:28:35 UTC (rev 22026)
+++ trunk/uClibc/libc/unistd/getopt_int.h 2008-05-20 20:32:27 UTC (rev 22027)
@@ -30,30 +30,30 @@
/* Reentrant versions which can handle parsing multiple argument
vectors at the same time. */
+enum
+ {
+ REQUIRE_ORDER, PERMUTE, RETURN_IN_ORDER
+ };
+
/* Data type for reentrant functions. */
struct _getopt_data
{
/* These have exactly the same meaning as the corresponding global
variables, except that they are used for the reentrant
versions of getopt. */
+ char *optarg;
int optind;
int opterr;
int optopt;
- char *optarg;
/* Internal members. */
/* True if the internal members have been initialized. */
- int __initialized;
+ smallint __initialized;
- /* The next char to be scanned in the option-element
- in which the last option character we returned was found.
- This allows us to pick up the scan where we left off.
+ /* If the POSIXLY_CORRECT environment variable is set. */
+ smallint __posixly_correct;
- If this is zero, or a null string, it means resume the scan
- by advancing to the next ARGV-element. */
- char *__nextchar;
-
/* Describe how to deal with options that follow non-option ARGV-elements.
If the caller did not specify anything,
@@ -82,16 +82,16 @@
The special argument `--' forces an end of option-scanning regardless
of the value of `ordering'. In the case of RETURN_IN_ORDER, only
`--' can cause `getopt' to return -1 with `optind' != ARGC. */
+ smallint __ordering;
- enum
- {
- REQUIRE_ORDER, PERMUTE, RETURN_IN_ORDER
- } __ordering;
+ /* The next char to be scanned in the option-element
+ in which the last option character we returned was found.
+ This allows us to pick up the scan where we left off.
- /* If the POSIXLY_CORRECT environment variable is set. */
- int __posixly_correct;
+ If this is zero, or a null string, it means resume the scan
+ by advancing to the next ARGV-element. */
+ char *__nextchar;
-
/* Handle permutation of arguments. */
/* Describe the part of ARGV that contains non-options that have
More information about the uClibc-cvs
mailing list