Util-Linux package development
 help / color / mirror / Atom feed
* [PATCH] getopt: [getopt.c] add static qualifiers
       [not found] <1301243396-26240-1-git-send-email-dolmen@cpan.org>
@ 2011-03-27 16:29 ` Olivier Mengué
       [not found]   ` <1301355571.2073.1.camel@offworld>
  0 siblings, 1 reply; 3+ messages in thread
From: Olivier Mengué @ 2011-03-27 16:29 UTC (permalink / raw)
  To: util-linux; +Cc: Olivier Mengué

Signed-off-by: Olivier Mengué <dolmen@cpan.org>
---
 getopt/getopt.c |   52 ++++++++++++++++++++++++++--------------------------
 1 files changed, 26 insertions(+), 26 deletions(-)

diff --git a/getopt/getopt.c b/getopt/getopt.c
index cea2f22..2e7109d 100644
--- a/getopt/getopt.c
+++ b/getopt/getopt.c
@@ -59,27 +59,27 @@ typedef enum {BASH,TCSH} shell_t;
 
 
 /* Some global variables that tells us how to parse. */
-shell_t shell=BASH; /* The shell we generate output for. */
-int quiet_errors=0; /* 0 is not quiet. */
-int quiet_output=0; /* 0 is not quiet. */
-int quote=1; /* 1 is do quote. */
-int alternative=0; /* 0 is getopt_long, 1 is getopt_long_only */
+static shell_t shell=BASH; /* The shell we generate output for. */
+static int quiet_errors=0; /* 0 is not quiet. */
+static int quiet_output=0; /* 0 is not quiet. */
+static int quote=1; /* 1 is do quote. */
+static int alternative=0; /* 0 is getopt_long, 1 is getopt_long_only */
 
 /* Function prototypes */
-void *our_malloc(size_t size);
-void *our_realloc(void *ptr, size_t size);
-const char *normalize(const char *arg);
-int generate_output(char * argv[],int argc,const char *optstr,
-                    const struct option *longopts);
+static void *our_malloc(size_t size);
+static void *our_realloc(void *ptr, size_t size);
+static const char *normalize(const char *arg);
+static int generate_output(char * argv[],int argc,const char *optstr,
+                           const struct option *longopts);
 int main(int argc, char *argv[]);
-void parse_error(const char *message);
-void add_long_options(char *options);
-void add_longopt(const char *name,int has_arg);
-void print_help(void);
-void set_shell(const char *new_shell);
-void set_initial_shell(void);
-
-void *our_malloc(size_t size)
+static void parse_error(const char *message);
+static void add_long_options(char *options);
+static void add_longopt(const char *name,int has_arg);
+static void print_help(void);
+static void set_shell(const char *new_shell);
+static void set_initial_shell(void);
+
+static void *our_malloc(size_t size)
 {
 	void *ret=malloc(size);
 	if (! ret) {
@@ -89,7 +89,7 @@ void *our_malloc(size_t size)
 	return(ret);
 }
 
-void *our_realloc(void *ptr, size_t size)
+static void *our_realloc(void *ptr, size_t size)
 {
 	void *ret=realloc(ptr,size);
 	if (! ret && size) {
@@ -108,7 +108,7 @@ void *our_realloc(void *ptr, size_t size)
  * This function returns a pointer to a buffer that is overwritten by 
  * each call.
  */
-const char *normalize(const char *arg)
+static const char *normalize(const char *arg)
 {
 	static char *BUFFER=NULL;
 	const char *argptr=arg;
@@ -172,8 +172,8 @@ const char *normalize(const char *arg)
  * optstr must contain the short options, and longopts the long options.
  * Other settings are found in global variables.
  */
-int generate_output(char * argv[],int argc,const char *optstr,
-                    const struct option *longopts)
+static int generate_output(char * argv[],int argc,const char *optstr,
+                           const struct option *longopts)
 {
 	int exit_code = 0; /* We assume everything will be OK */
 	int opt;
@@ -222,7 +222,7 @@ int generate_output(char * argv[],int argc,const char *optstr,
  * If message is NULL, we already sent a message, we just exit with a helpful
  * hint.
  */
-void parse_error(const char *message)
+static void parse_error(const char *message)
 {
 	if (message)
 		fprintf(stderr,"getopt: %s\n",message);
@@ -237,7 +237,7 @@ static int long_options_nr=0; /* Nr of used elements in array */
 #define init_longopt() add_longopt(NULL,0)
 
 /* Register a long option. The contents of name is copied. */
-void add_longopt(const char *name,int has_arg)
+static void add_longopt(const char *name,int has_arg)
 {
 	char *tmp;
 	if (!name) { /* init */
@@ -276,7 +276,7 @@ void add_longopt(const char *name,int has_arg)
  * separated by commas or whitespace. 
  * This nukes options! 
  */
-void add_long_options(char *options)
+static void add_long_options(char *options)
 {
 	int arg_opt;
 	char *tokptr=strtok(options,", \t\n");
@@ -301,7 +301,7 @@ void add_long_options(char *options)
 	}
 }
 
-void set_shell(const char *new_shell)
+static void set_shell(const char *new_shell)
 {
 	if (!strcmp(new_shell,"bash"))
 		shell=BASH;
@@ -315,7 +315,7 @@ void set_shell(const char *new_shell)
 		parse_error(_("unknown shell after -s or --shell argument"));
 }
 
-void print_help(void)
+static void print_help(void)
 {
 	fputs(_("Usage: getopt optstring parameters\n"),stderr);
 	fputs(_("       getopt [options] [--] optstring parameters\n"),stderr);
-- 
1.7.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] getopt: [getopt.c] add static qualifiers
       [not found]   ` <1301355571.2073.1.camel@offworld>
@ 2011-04-09  8:17     ` Olivier Mengué
  2011-04-11 10:37       ` Karel Zak
  0 siblings, 1 reply; 3+ messages in thread
From: Olivier Mengué @ 2011-04-09  8:17 UTC (permalink / raw)
  To: Davidlohr Bueso; +Cc: util-linux

I've noticed my patch has been committed in
0a626987e244b6fa30c18cfa86d12cd80b3977e8.
Thanks.

Le 29 mars 2011 01:39, Davidlohr Bueso <dave@gnu.org> a écrit :
>
> On Sun, 2011-03-27 at 18:29 +0200, Olivier Mengué wrote:
> > -void *our_malloc(size_t size);
> > -void *our_realloc(void *ptr, size_t size);
>
> It would be nice to use our xalloc lib for stuff like this.

Working on a patch for that.
However, note that xalloc error messages are not localized contrary to
the current implementation.

> > -void print_help(void)
> > +static void print_help(void)
>
> Lately we've been standardizing this kind of things too.

A real cleanup of this function would require to also merge the
multiple fputs() calls. This would have impact on localization.
What is the policy on changes having impact on localization? (Please,
add the answer to README.devel too).

Olivier.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] getopt: [getopt.c] add static qualifiers
  2011-04-09  8:17     ` Olivier Mengué
@ 2011-04-11 10:37       ` Karel Zak
  0 siblings, 0 replies; 3+ messages in thread
From: Karel Zak @ 2011-04-11 10:37 UTC (permalink / raw)
  To: Olivier Mengué; +Cc: Davidlohr Bueso, util-linux

On Sat, Apr 09, 2011 at 10:17:58AM +0200, Olivier Mengué wrote:
> I've noticed my patch has been committed in
> 0a626987e244b6fa30c18cfa86d12cd80b3977e8.
> Thanks.
> 
> Le 29 mars 2011 01:39, Davidlohr Bueso <dave@gnu.org> a écrit :
> >
> > On Sun, 2011-03-27 at 18:29 +0200, Olivier Mengué wrote:
> > > -void *our_malloc(size_t size);
> > > -void *our_realloc(void *ptr, size_t size);
> >
> > It would be nice to use our xalloc lib for stuff like this.
> 
> Working on a patch for that.
> However, note that xalloc error messages are not localized contrary to
> the current implementation.

Hmm.. it should be probably fixed.

> > > -void print_help(void)
> > > +static void print_help(void)
> >
> > Lately we've been standardizing this kind of things too.
> 
> A real cleanup of this function would require to also merge the
> multiple fputs() calls. This would have impact on localization.
> What is the policy on changes having impact on localization? (Please,
> add the answer to README.devel too).

Don't care about localization, the strings will be translated before
release.

    Karel

-- 
 Karel Zak  <kzak@redhat.com>
 http://karelzak.blogspot.com

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2011-04-11 10:37 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <1301243396-26240-1-git-send-email-dolmen@cpan.org>
2011-03-27 16:29 ` [PATCH] getopt: [getopt.c] add static qualifiers Olivier Mengué
     [not found]   ` <1301355571.2073.1.camel@offworld>
2011-04-09  8:17     ` Olivier Mengué
2011-04-11 10:37       ` Karel Zak

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox