From 419e5eff6494c6efbbfb007c42e28e5eb54716b2 Mon Sep 17 00:00:00 2001 From: James Youngman Date: Thu, 1 Apr 2010 00:06:23 +0100 Subject: [PATCH] Coding style fixes: space after function names. * lib/buildcmd.c: Insert a space between function name and open parenthesis. * lib/dircallback.c: Likewise. * lib/extendbuf.c: Likewise. * lib/fdleak.c: Likewise. * lib/findutils-version.c: Likewise. * lib/forcefindlib.c: Likewise. * lib/listfile.c: Likewise. * lib/printquoted.c: Likewise. * lib/qmark.c: Likewise. * lib/regexprops.c: Likewise. * lib/regextype.c: Likewise. * lib/savedirinfo.c: Likewise. Signed-off-by: James Youngman --- ChangeLog | 17 ++ lib/buildcmd.c | 62 +++--- lib/dircallback.c | 2 +- lib/extendbuf.c | 12 +- lib/fdleak.c | 12 +- lib/findutils-version.c | 16 +- lib/forcefindlib.c | 6 +- lib/listfile.c | 16 +- lib/printquoted.c | 12 +- lib/qmark.c | 8 +- lib/regexprops.c | 456 ++++++++++++++++++++-------------------- lib/regextype.c | 28 +-- lib/savedirinfo.c | 72 +++---- 13 files changed, 368 insertions(+), 351 deletions(-) diff --git a/ChangeLog b/ChangeLog index 3f3b4b19..a6a5d507 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,20 @@ +2010-04-01 James Youngman + + Coding style fixes: space after function names. + * lib/buildcmd.c: Insert a space between function name and open + parenthesis. + * lib/dircallback.c: Likewise. + * lib/extendbuf.c: Likewise. + * lib/fdleak.c: Likewise. + * lib/findutils-version.c: Likewise. + * lib/forcefindlib.c: Likewise. + * lib/listfile.c: Likewise. + * lib/printquoted.c: Likewise. + * lib/qmark.c: Likewise. + * lib/regexprops.c: Likewise. + * lib/regextype.c: Likewise. + * lib/savedirinfo.c: Likewise. + 2010-03-31 James Youngman Coding style fixes: space after function names. diff --git a/lib/buildcmd.c b/lib/buildcmd.c index 3f35ab4f..c279d229 100644 --- a/lib/buildcmd.c +++ b/lib/buildcmd.c @@ -1,6 +1,6 @@ /* buildcmd.c -- build command lines from a list of arguments. Copyright (C) 1990, 91, 92, 93, 94, 2000, 2003, 2005, 2006, - 2007, 2008 Free Software Foundation, Inc. + 2007, 2008, 2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -281,8 +281,8 @@ copy_args (struct buildcmd_control *ctl, /* Execute the program with the currently-built list of arguments. */ void -bc_do_exec(struct buildcmd_control *ctl, - struct buildcmd_state *state) +bc_do_exec (struct buildcmd_control *ctl, + struct buildcmd_state *state) { char** working_args; size_t limit, done; @@ -293,7 +293,7 @@ bc_do_exec(struct buildcmd_control *ctl, assert (state->cmd_argc > 0); assert (state->cmd_argv[state->cmd_argc-1] == NULL); - working_args = xmalloc((1+state->cmd_argc) * sizeof(char*)); + working_args = xmalloc ((1+state->cmd_argc) * sizeof (char*)); done = 0; limit = state->cmd_argc; @@ -312,8 +312,8 @@ bc_do_exec(struct buildcmd_control *ctl, { /* No room to reduce the length of the argument list. Issue an error message and give up. */ - error(1, 0, - _("can't call exec() due to argument size restrictions")); + error (1, 0, + _("can't call exec() due to argument size restrictions")); } else { @@ -328,7 +328,7 @@ bc_do_exec(struct buildcmd_control *ctl, if (working_args) free (working_args); - bc_clear_args(ctl, state); + bc_clear_args (ctl, state); } @@ -340,9 +340,9 @@ bc_do_exec(struct buildcmd_control *ctl, * argument, depending on its length. */ static int -bc_argc_limit_reached(int initial_args, - const struct buildcmd_control *ctl, - struct buildcmd_state *state) +bc_argc_limit_reached (int initial_args, + const struct buildcmd_control *ctl, + struct buildcmd_state *state) { /* Check to see if we about to exceed a limit set by xargs' -n option */ if (!initial_args && ctl->args_per_exec && @@ -391,7 +391,7 @@ bc_push_arg (struct buildcmd_control *ctl, error (1, 0, _("argument list too long")); bc_do_exec (ctl, state); } - if (bc_argc_limit_reached(initial_args, ctl, state)) + if (bc_argc_limit_reached (initial_args, ctl, state)) bc_do_exec (ctl, state); } @@ -428,7 +428,7 @@ bc_push_arg (struct buildcmd_control *ctl, /* If we have now collected enough arguments, * do the exec immediately. */ - if (bc_argc_limit_reached(initial_args, ctl, state)) + if (bc_argc_limit_reached (initial_args, ctl, state)) { bc_do_exec (ctl, state); } @@ -446,11 +446,11 @@ bc_push_arg (struct buildcmd_control *ctl, * currently we use _POSIX_ARG_MAX (which is the minimum value). */ static size_t -get_line_max(void) +get_line_max (void) { long val; #ifdef _SC_LINE_MAX - val = sysconf(_SC_LINE_MAX); + val = sysconf (_SC_LINE_MAX); #else val = -1; #endif @@ -473,7 +473,7 @@ get_line_max(void) #endif size_t -bc_get_arg_max(void) +bc_get_arg_max (void) { long val; @@ -482,7 +482,7 @@ bc_get_arg_max(void) assert ( (~(size_t)0) >= LONG_MAX); #ifdef _SC_ARG_MAX - val = sysconf(_SC_ARG_MAX); + val = sysconf (_SC_ARG_MAX); #else val = -1; #endif @@ -511,10 +511,10 @@ bc_get_arg_max(void) static int -cb_exec_noop(struct buildcmd_control * ctl, - void *usercontext, - int argc, - char **argv) +cb_exec_noop (struct buildcmd_control * ctl, + void *usercontext, + int argc, + char **argv) { /* does nothing. */ (void) ctl; @@ -541,17 +541,17 @@ bc_size_of_environment (void) enum BC_INIT_STATUS -bc_init_controlinfo(struct buildcmd_control *ctl, - size_t headroom) +bc_init_controlinfo (struct buildcmd_control *ctl, + size_t headroom) { - size_t size_of_environment = bc_size_of_environment(); + size_t size_of_environment = bc_size_of_environment (); /* POSIX requires that _POSIX_ARG_MAX is 4096. That is the lowest * possible value for ARG_MAX on a POSIX compliant system. See * http://www.opengroup.org/onlinepubs/009695399/basedefs/limits.h.html */ ctl->posix_arg_size_min = _POSIX_ARG_MAX; - ctl->posix_arg_size_max = bc_get_arg_max(); + ctl->posix_arg_size_max = bc_get_arg_max (); ctl->exit_if_size_exceeded = 0; @@ -576,7 +576,7 @@ bc_init_controlinfo(struct buildcmd_control *ctl, } /* need to subtract 2 on the following line - for Linux/PPC */ - ctl->max_arg_count = (ctl->posix_arg_size_max / sizeof(char*)) - 2u; + ctl->max_arg_count = (ctl->posix_arg_size_max / sizeof (char*)) - 2u; assert (ctl->max_arg_count > 0); ctl->rplen = 0u; ctl->replace_pat = NULL; @@ -594,7 +594,7 @@ bc_init_controlinfo(struct buildcmd_control *ctl, } void -bc_use_sensible_arg_max(struct buildcmd_control *ctl) +bc_use_sensible_arg_max (struct buildcmd_control *ctl) { #ifdef DEFAULT_ARG_SIZE enum { arg_size = DEFAULT_ARG_SIZE }; @@ -615,9 +615,9 @@ bc_use_sensible_arg_max(struct buildcmd_control *ctl) void -bc_init_state(const struct buildcmd_control *ctl, - struct buildcmd_state *state, - void *context) +bc_init_state (const struct buildcmd_control *ctl, + struct buildcmd_state *state, + void *context) { state->cmd_argc = 0; state->cmd_argv_chars = 0; @@ -641,8 +641,8 @@ bc_init_state(const struct buildcmd_control *ctl, } void -bc_clear_args(const struct buildcmd_control *ctl, - struct buildcmd_state *state) +bc_clear_args (const struct buildcmd_control *ctl, + struct buildcmd_state *state) { state->cmd_argc = ctl->initial_argc; state->cmd_argv_chars = state->cmd_initial_argv_chars; diff --git a/lib/dircallback.c b/lib/dircallback.c index b7bca0ac..1c11c5ad 100644 --- a/lib/dircallback.c +++ b/lib/dircallback.c @@ -1,5 +1,5 @@ /* listfile.c -- run a function in a specific directory - Copyright (C) 2007, 2008, 2009 Free Software Foundation, Inc. + Copyright (C) 2007, 2008, 2009, 2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/lib/extendbuf.c b/lib/extendbuf.c index bc98900e..e5aa0746 100644 --- a/lib/extendbuf.c +++ b/lib/extendbuf.c @@ -1,6 +1,6 @@ /* extendbuf.c -- manage a dynamically-allocated buffer - Copyright 2004 Free Software Foundation, Inc. + Copyright 2004, 2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -37,7 +37,7 @@ #endif static size_t -decide_size(size_t current, size_t wanted) +decide_size (size_t current, size_t wanted) { size_t newsize; @@ -57,7 +57,7 @@ decide_size(size_t current, size_t wanted) void * -extendbuf(void* existing, size_t wanted, size_t *allocated) +extendbuf (void* existing, size_t wanted, size_t *allocated) { int saved_errno; size_t newsize; @@ -66,7 +66,7 @@ extendbuf(void* existing, size_t wanted, size_t *allocated) saved_errno = errno; assert (wanted > 0u); - newsize = decide_size(*allocated, wanted); + newsize = decide_size (*allocated, wanted); if ( (*allocated) == 0 ) { @@ -76,7 +76,7 @@ extendbuf(void* existing, size_t wanted, size_t *allocated) assert (NULL == existing); (*allocated) = newsize; - result = xmalloc(newsize); + result = xmalloc (newsize); } else { @@ -94,7 +94,7 @@ extendbuf(void* existing, size_t wanted, size_t *allocated) if (result) { - /* xmalloc() or xrealloc() may have changed errno, but in the + /* xmalloc () or xrealloc () may have changed errno, but in the success case we want to preserve the previous value. */ errno = saved_errno; diff --git a/lib/fdleak.c b/lib/fdleak.c index 243c2ed4..577e7899 100644 --- a/lib/fdleak.c +++ b/lib/fdleak.c @@ -138,8 +138,8 @@ get_max_fd (void) static int -visit_open_fds(int fd_min, int fd_max, - int (*callback)(int, void*), void *cb_context) +visit_open_fds (int fd_min, int fd_max, + int (*callback)(int, void*), void *cb_context) { enum { MAX_POLL = 64 }; struct pollfd pf[MAX_POLL]; @@ -158,7 +158,7 @@ visit_open_fds(int fd_min, int fd_max, pf[i].revents = 0; pf[i].fd = fd_min + i; } - rv = poll(pf, limit, 0); + rv = poll (pf, limit, 0); if (-1 == rv) { return -1; @@ -209,7 +209,7 @@ remember_fd_if_non_cloexec (int fd, void *context) { struct remember_fd_context * const p = context; void *newbuf = extendbuf (p->buf, - sizeof(p->buf[0])*(p->used+1), + sizeof (p->buf[0])*(p->used+1), &(p->allocated)); if (newbuf) { @@ -355,8 +355,8 @@ complain_about_leaky_fds (void) { char * const args[] = {"/bin/ls", "-l", "/proc/self/fd", (char*)NULL }; - execv("/bin/ls", args); - perror("exec"); + execv ("/bin/ls", args); + perror ("exec"); } } assert (no_leaks); diff --git a/lib/findutils-version.c b/lib/findutils-version.c index 291a23d8..f3ada258 100644 --- a/lib/findutils-version.c +++ b/lib/findutils-version.c @@ -1,5 +1,5 @@ /* findutils-version.c -- show version information for findutils - Copyright (C) 2007 Free Software Foundation, Inc. + Copyright (C) 2007, 2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -48,18 +48,18 @@ char *version_string = VERSION; void -display_findutils_version(const char *official_name) +display_findutils_version (const char *official_name) { /* We use official_name rather than program name in the version * information. This is deliberate, it is specified by the * GNU coding standard. */ fflush (stderr); - version_etc(stdout, - official_name, PACKAGE_NAME, version_string, - _("Eric B. Decker"), - _("James Youngman"), - _("Kevin Dalley"), - (const char*) NULL); + version_etc (stdout, + official_name, PACKAGE_NAME, version_string, + _("Eric B. Decker"), + _("James Youngman"), + _("Kevin Dalley"), + (const char*) NULL); printf (_("Built using GNU gnulib version %s\n"), gnulib_version); } diff --git a/lib/forcefindlib.c b/lib/forcefindlib.c index fb749611..63199c89 100644 --- a/lib/forcefindlib.c +++ b/lib/forcefindlib.c @@ -1,5 +1,5 @@ /* Ensures that the FINDLIB_REPLACE_FUNCS macro in configure.in works - Copyright (C) 2004 Free Software Foundation, Inc. + Copyright (C) 2004, 2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -22,7 +22,7 @@ #include -extern void forcefindlib(void); /* prevent GCC warning... */ +extern void forcefindlib (void); /* prevent GCC warning... */ @@ -41,7 +41,7 @@ extern void forcefindlib(void); /* prevent GCC warning... */ * is forcefindlib(). */ void -forcefindlib(void) +forcefindlib (void) { /* does nothing, exists only to ensure that FINDLIB_REPLACE_FUNCS works. */ } diff --git a/lib/listfile.c b/lib/listfile.c index e8989793..392245ab 100644 --- a/lib/listfile.c +++ b/lib/listfile.c @@ -1,6 +1,6 @@ /* listfile.c -- display a long listing of a file Copyright (C) 1991, 1993, 2000, 2004, 2005, 2007, - 2008 Free Software Foundation, Inc. + 2008, 2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -165,7 +165,7 @@ static void print_name (register const char *p, FILE *stream, int literal_contro size_t -file_blocksize(const struct stat *p) +file_blocksize (const struct stat *p) { return ST_NBLOCKSIZE; } @@ -313,7 +313,7 @@ list_file (const char *name, static void print_name_without_quoting (const char *p, FILE *stream) { - fprintf(stream, "%s", p); + fprintf (stream, "%s", p); } @@ -370,9 +370,9 @@ print_name_with_quoting (register const char *p, FILE *stream) static void print_name (register const char *p, FILE *stream, int literal_control_chars) { if (literal_control_chars) - print_name_without_quoting(p, stream); + print_name_without_quoting (p, stream); else - print_name_with_quoting(p, stream); + print_name_with_quoting (p, stream); } #ifdef S_ISLNK @@ -406,10 +406,10 @@ struct link_name_args }; static int -get_link_name_cb(void *context) +get_link_name_cb (void *context) { struct link_name_args *args = context; - args->result = get_link_name(args->name, args->relname); + args->result = get_link_name (args->name, args->relname); return 0; } @@ -420,7 +420,7 @@ get_link_name_at (const char *name, int dir_fd, char *relname) args.result = NULL; args.name = name; args.relname = relname; - if (0 == run_in_dir(dir_fd, get_link_name_cb, &args)) + if (0 == run_in_dir (dir_fd, get_link_name_cb, &args)) return args.result; else return NULL; diff --git a/lib/printquoted.c b/lib/printquoted.c index 1868f821..068ea4dc 100644 --- a/lib/printquoted.c +++ b/lib/printquoted.c @@ -1,7 +1,7 @@ /* printquoted.c -- print a specified string with any necessary quoting. - Copyright (C) 1990, 1991, 1992, 1993, 1994, 2000, - 2003, 2004, 2005, 2007, 2009 Free Software Foundation, Inc. + Copyright (C) 1990, 1991, 1992, 1993, 1994, 2000, 2003, 2004, 2005, + 2007, 2009, 2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -62,19 +62,19 @@ print_quoted (FILE *fp, } /* Replace any remaining funny characters with '?'. */ - len = qmark_chars(buf, len); + len = qmark_chars (buf, len); - rv = fprintf(fp, format, buf); /* Print the quoted version */ + rv = fprintf (fp, format, buf); /* Print the quoted version */ if (buf != smallbuf) { - free(buf); + free (buf); buf = NULL; } } else { /* no need to quote things. */ - rv = fprintf(fp, format, s); + rv = fprintf (fp, format, s); } return rv; } diff --git a/lib/qmark.c b/lib/qmark.c index 1f31c3b6..1ffd1d72 100644 --- a/lib/qmark.c +++ b/lib/qmark.c @@ -1,6 +1,6 @@ /* qmark.c -- quote 'dangerous' filenames - Copyright (C) 2005, 2007, 2009 Free Software Foundation, Inc. + Copyright (C) 2005, 2007, 2009, 2010 Free Software Foundation, Inc. Derived from courutils' ls.c: Copyright (C) 85, 88, 90, 91, 1995-2005 Free Software Foundation, Inc. @@ -84,7 +84,7 @@ static inline unsigned char to_uchar (char ch) static size_t -unibyte_qmark_chars(char *buf, size_t len) +unibyte_qmark_chars (char *buf, size_t len) { char *p = buf; char const *plimit = buf + len; @@ -110,11 +110,11 @@ unibyte_qmark_chars(char *buf, size_t len) * is returned. */ size_t -qmark_chars(char *buf, size_t len) +qmark_chars (char *buf, size_t len) { if (MB_CUR_MAX <= 1) { - return unibyte_qmark_chars(buf, len); + return unibyte_qmark_chars (buf, len); } else { diff --git a/lib/regexprops.c b/lib/regexprops.c index 30e1f9a3..a7528229 100644 --- a/lib/regexprops.c +++ b/lib/regexprops.c @@ -1,7 +1,7 @@ /* regexprops.c -- document the properties of the regular expressions - understood by gnulib. + understood by gnulib. - Copyright 2005, 2007 Free Software Foundation, Inc. + Copyright 2005, 2007, 2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -19,9 +19,9 @@ /* - The output of this program is included in the GNU findutils source - distribution. The copying conditions for that file are generated - by the copying() function below. + The output of this program is included in the GNU findutils source + distribution. The copying conditions for that file are generated + by the copying() function below. */ /* Written by James Youngman, . */ @@ -41,400 +41,400 @@ /* Name this program was run with. */ char *program_name; -static void output(const char *s, int escape) +static void output (const char *s, int escape) { (void) escape; - fputs(s, stdout); + fputs (s, stdout); } -static void newline(void) +static void newline (void) { - output("\n", 0); + output ("\n", 0); } -static void content(const char *s) +static void content (const char *s) { - output(s, 1); + output (s, 1); } -static void literal(const char *s) +static void literal (const char *s) { - output(s, 0); + output (s, 0); } -static void directive(const char *s) +static void directive (const char *s) { - output(s, 0); + output (s, 0); } -static void comment(const char *s) +static void comment (const char *s) { - directive("@c "); - literal(s); - newline(); + directive ("@c "); + literal (s); + newline (); } -static void enum_item(const char *s) +static void enum_item (const char *s) { - newline(); - directive("@item "); - literal(s); - newline(); + newline (); + directive ("@item "); + literal (s); + newline (); } -static void begin_subsection(const char *name, - const char *next, - const char *prev, - const char *up) +static void begin_subsection (const char *name, + const char *next, + const char *prev, + const char *up) { (void) next; (void) prev; (void) up; - newline(); + newline (); - directive("@node "); - content(name); - content(" regular expression syntax"); - newline(); + directive ("@node "); + content (name); + content (" regular expression syntax"); + newline (); - directive("@subsection "); - output("@samp{", 0); - content(name); - output("}", 0); - content(" regular expression syntax"); - newline(); + directive ("@subsection "); + output ("@samp{", 0); + content (name); + output ("}", 0); + content (" regular expression syntax"); + newline (); } -static void begintable_markup(char const *markup) +static void begintable_markup (char const *markup) { - newline(); - directive("@table "); - literal(markup); - newline(); + newline (); + directive ("@table "); + literal (markup); + newline (); } -static void endtable() +static void endtable () { - newline(); - directive("@end table"); - newline(); + newline (); + directive ("@end table"); + newline (); } -static void beginenum() +static void beginenum () { - newline(); - directive("@enumerate"); - newline(); + newline (); + directive ("@enumerate"); + newline (); } -static void endenum() +static void endenum () { - newline(); - directive("@end enumerate"); - newline(); + newline (); + directive ("@end enumerate"); + newline (); } -static void newpara() +static void newpara () { - content("\n\n"); + content ("\n\n"); } static void -describe_regex_syntax(int options) +describe_regex_syntax (int options) { - newpara(); - content("The character @samp{.} matches any single character"); + newpara (); + content ("The character @samp{.} matches any single character"); if ( (options & RE_DOT_NEWLINE) == 0 ) { - content(" except newline"); + content (" except newline"); } if (options & RE_DOT_NOT_NULL) { if ( (options & RE_DOT_NEWLINE) == 0 ) - content(" and"); + content (" and"); else - content(" except"); + content (" except"); - content(" the null character"); + content (" the null character"); } - content(". "); - newpara(); + content (". "); + newpara (); if (!(options & RE_LIMITED_OPS)) { - begintable_markup("@samp"); + begintable_markup ("@samp"); if (options & RE_BK_PLUS_QM) { - enum_item("\\+"); - content("indicates that the regular expression should match one" - " or more occurrences of the previous atom or regexp. "); - enum_item("\\?"); - content("indicates that the regular expression should match zero" - " or one occurrence of the previous atom or regexp. "); - enum_item("+ and ? "); - content("match themselves. "); + enum_item ("\\+"); + content ("indicates that the regular expression should match one" + " or more occurrences of the previous atom or regexp. "); + enum_item ("\\?"); + content ("indicates that the regular expression should match zero" + " or one occurrence of the previous atom or regexp. "); + enum_item ("+ and ? "); + content ("match themselves. "); } else { - enum_item("+"); - content("indicates that the regular expression should match one" - " or more occurrences of the previous atom or regexp. "); - enum_item("?"); - content("indicates that the regular expression should match zero" - " or one occurrence of the previous atom or regexp. "); - enum_item("\\+"); - literal("matches a @samp{+}"); - enum_item("\\?"); - literal("matches a @samp{?}. "); + enum_item ("+"); + content ("indicates that the regular expression should match one" + " or more occurrences of the previous atom or regexp. "); + enum_item ("?"); + content ("indicates that the regular expression should match zero" + " or one occurrence of the previous atom or regexp. "); + enum_item ("\\+"); + literal ("matches a @samp{+}"); + enum_item ("\\?"); + literal ("matches a @samp{?}. "); } - endtable(); + endtable (); } - newpara(); + newpara (); - content("Bracket expressions are used to match ranges of characters. "); - literal("Bracket expressions where the range is backward, for example @samp{[z-a]}, are "); + content ("Bracket expressions are used to match ranges of characters. "); + literal ("Bracket expressions where the range is backward, for example @samp{[z-a]}, are "); if (options & RE_NO_EMPTY_RANGES) - content("invalid"); + content ("invalid"); else - content("ignored"); - content(". "); + content ("ignored"); + content (". "); if (options & RE_BACKSLASH_ESCAPE_IN_LISTS) - literal("Within square brackets, @samp{\\} can be used to quote " - "the following character. "); + literal ("Within square brackets, @samp{\\} can be used to quote " + "the following character. "); else - literal("Within square brackets, @samp{\\} is taken literally. "); + literal ("Within square brackets, @samp{\\} is taken literally. "); if (options & RE_CHAR_CLASSES) - content("Character classes are supported; for example " - "@samp{[[:digit:]]} will match a single decimal digit. "); + content ("Character classes are supported; for example " + "@samp{[[:digit:]]} will match a single decimal digit. "); else - literal("Character classes are not supported, so for example " - "you would need to use @samp{[0-9]} " - "instead of @samp{[[:digit:]]}. "); + literal ("Character classes are not supported, so for example " + "you would need to use @samp{[0-9]} " + "instead of @samp{[[:digit:]]}. "); if (options & RE_HAT_LISTS_NOT_NEWLINE) { - literal("Non-matching lists @samp{[^@dots{}]} do not ever match newline. "); + literal ("Non-matching lists @samp{[^@dots{}]} do not ever match newline. "); } - newpara(); + newpara (); if (options & RE_NO_GNU_OPS) { - content("GNU extensions are not supported and so " - "@samp{\\w}, @samp{\\W}, @samp{\\<}, @samp{\\>}, @samp{\\b}, @samp{\\B}, @samp{\\`}, and @samp{\\'} " - "match " - "@samp{w}, @samp{W}, @samp{<}, @samp{>}, @samp{b}, @samp{B}, @samp{`}, and @samp{'} respectively. "); + content ("GNU extensions are not supported and so " + "@samp{\\w}, @samp{\\W}, @samp{\\<}, @samp{\\>}, @samp{\\b}, @samp{\\B}, @samp{\\`}, and @samp{\\'} " + "match " + "@samp{w}, @samp{W}, @samp{<}, @samp{>}, @samp{b}, @samp{B}, @samp{`}, and @samp{'} respectively. "); } else { - content("GNU extensions are supported:"); - beginenum(); - enum_item("@samp{\\w} matches a character within a word"); - enum_item("@samp{\\W} matches a character which is not within a word"); - enum_item("@samp{\\<} matches the beginning of a word"); - enum_item("@samp{\\>} matches the end of a word"); - enum_item("@samp{\\b} matches a word boundary"); - enum_item("@samp{\\B} matches characters which are not a word boundary"); - enum_item("@samp{\\`} matches the beginning of the whole input"); - enum_item("@samp{\\'} matches the end of the whole input"); - endenum(); + content ("GNU extensions are supported:"); + beginenum (); + enum_item ("@samp{\\w} matches a character within a word"); + enum_item ("@samp{\\W} matches a character which is not within a word"); + enum_item ("@samp{\\<} matches the beginning of a word"); + enum_item ("@samp{\\>} matches the end of a word"); + enum_item ("@samp{\\b} matches a word boundary"); + enum_item ("@samp{\\B} matches characters which are not a word boundary"); + enum_item ("@samp{\\`} matches the beginning of the whole input"); + enum_item ("@samp{\\'} matches the end of the whole input"); + endenum (); } - newpara(); + newpara (); if (options & RE_NO_BK_PARENS) { - literal("Grouping is performed with parentheses @samp{()}. "); + literal ("Grouping is performed with parentheses @samp{()}. "); if (options & RE_UNMATCHED_RIGHT_PAREN_ORD) - literal("An unmatched @samp{)} matches just itself. "); + literal ("An unmatched @samp{)} matches just itself. "); } else { - literal("Grouping is performed with backslashes followed by parentheses @samp{\\(}, @samp{\\)}. "); + literal ("Grouping is performed with backslashes followed by parentheses @samp{\\(}, @samp{\\)}. "); } if (options & RE_NO_BK_REFS) { - content("A backslash followed by a digit matches that digit. "); + content ("A backslash followed by a digit matches that digit. "); } else { - literal("A backslash followed by a digit acts as a back-reference and matches the same thing as the previous grouped expression indicated by that number. For example @samp{\\2} matches the second group expression. The order of group expressions is determined by the position of their opening parenthesis "); + literal ("A backslash followed by a digit acts as a back-reference and matches the same thing as the previous grouped expression indicated by that number. For example @samp{\\2} matches the second group expression. The order of group expressions is determined by the position of their opening parenthesis "); if (options & RE_NO_BK_PARENS) - literal("@samp{(}"); + literal ("@samp{(}"); else - literal("@samp{\\(}"); - content(". "); + literal ("@samp{\\(}"); + content (". "); } - newpara(); + newpara (); if (!(options & RE_LIMITED_OPS)) { if (options & RE_NO_BK_VBAR) - literal("The alternation operator is @samp{|}. "); + literal ("The alternation operator is @samp{|}. "); else - literal("The alternation operator is @samp{\\|}. "); + literal ("The alternation operator is @samp{\\|}. "); } - newpara(); + newpara (); if (options & RE_CONTEXT_INDEP_ANCHORS) { - literal("The characters @samp{^} and @samp{$} always represent the beginning and end of a string respectively, except within square brackets. Within brackets, @samp{^} can be used to invert the membership of the character class being specified. "); + literal ("The characters @samp{^} and @samp{$} always represent the beginning and end of a string respectively, except within square brackets. Within brackets, @samp{^} can be used to invert the membership of the character class being specified. "); } else { - literal("The character @samp{^} only represents the beginning of a string when it appears:"); - beginenum(); - enum_item("\nAt the beginning of a regular expression"); - enum_item("After an open-group, signified by "); + literal ("The character @samp{^} only represents the beginning of a string when it appears:"); + beginenum (); + enum_item ("\nAt the beginning of a regular expression"); + enum_item ("After an open-group, signified by "); if (options & RE_NO_BK_PARENS) { - literal("@samp{(}"); + literal ("@samp{(}"); } else { - literal("@samp{\\(}"); + literal ("@samp{\\(}"); } - newline(); + newline (); if (!(options & RE_LIMITED_OPS)) { if (options & RE_NEWLINE_ALT) - enum_item("After a newline"); + enum_item ("After a newline"); if (options & RE_NO_BK_VBAR ) - enum_item("After the alternation operator @samp{|}"); + enum_item ("After the alternation operator @samp{|}"); else - enum_item("After the alternation operator @samp{\\|}"); + enum_item ("After the alternation operator @samp{\\|}"); } - endenum(); + endenum (); - newpara(); - literal("The character @samp{$} only represents the end of a string when it appears:"); - beginenum(); - enum_item("At the end of a regular expression"); - enum_item("Before a close-group, signified by "); + newpara (); + literal ("The character @samp{$} only represents the end of a string when it appears:"); + beginenum (); + enum_item ("At the end of a regular expression"); + enum_item ("Before a close-group, signified by "); if (options & RE_NO_BK_PARENS) { - literal("@samp{)}"); + literal ("@samp{)}"); } else { - literal("@samp{\\)}"); + literal ("@samp{\\)}"); } if (!(options & RE_LIMITED_OPS)) { if (options & RE_NEWLINE_ALT) - enum_item("Before a newline"); + enum_item ("Before a newline"); if (options & RE_NO_BK_VBAR) - enum_item("Before the alternation operator @samp{|}"); + enum_item ("Before the alternation operator @samp{|}"); else - enum_item("Before the alternation operator @samp{\\|}"); + enum_item ("Before the alternation operator @samp{\\|}"); } - endenum(); + endenum (); } - newpara(); + newpara (); if (!(options & RE_LIMITED_OPS) ) { if ((options & RE_CONTEXT_INDEP_OPS) && !(options & RE_CONTEXT_INVALID_OPS)) { - literal("The characters @samp{*}, @samp{+} and @samp{?} are special anywhere in a regular expression. "); + literal ("The characters @samp{*}, @samp{+} and @samp{?} are special anywhere in a regular expression. "); } else { if (options & RE_BK_PLUS_QM) - literal("@samp{\\*}, @samp{\\+} and @samp{\\?} "); + literal ("@samp{\\*}, @samp{\\+} and @samp{\\?} "); else - literal("@samp{*}, @samp{+} and @samp{?} "); + literal ("@samp{*}, @samp{+} and @samp{?} "); if (options & RE_CONTEXT_INVALID_OPS) { - content("are special at any point in a regular expression except the following places, where they are not allowed:"); + content ("are special at any point in a regular expression except the following places, where they are not allowed:"); } else { - content("are special at any point in a regular expression except:"); + content ("are special at any point in a regular expression except:"); } - beginenum(); - enum_item("At the beginning of a regular expression"); - enum_item("After an open-group, signified by "); + beginenum (); + enum_item ("At the beginning of a regular expression"); + enum_item ("After an open-group, signified by "); if (options & RE_NO_BK_PARENS) { - literal("@samp{(}"); + literal ("@samp{(}"); } else { - literal("@samp{\\(}"); + literal ("@samp{\\(}"); } if (!(options & RE_LIMITED_OPS)) { if (options & RE_NEWLINE_ALT) - enum_item("After a newline"); + enum_item ("After a newline"); if (options & RE_NO_BK_VBAR) - enum_item("After the alternation operator @samp{|}"); + enum_item ("After the alternation operator @samp{|}"); else - enum_item("After the alternation operator @samp{\\|}"); + enum_item ("After the alternation operator @samp{\\|}"); } - endenum(); + endenum (); } } - newpara(); + newpara (); if (options & RE_INTERVALS) { if (options & RE_NO_BK_BRACES) { - literal("Intervals are specified by @samp{@{} and @samp{@}}. "); + literal ("Intervals are specified by @samp{@{} and @samp{@}}. "); if (options & RE_INVALID_INTERVAL_ORD) { - literal("Invalid intervals are treated as literals, for example @samp{a@{1} is treated as @samp{a\\@{1}"); + literal ("Invalid intervals are treated as literals, for example @samp{a@{1} is treated as @samp{a\\@{1}"); } else { - literal("Invalid intervals such as @samp{a@{1z} are not accepted. "); + literal ("Invalid intervals such as @samp{a@{1z} are not accepted. "); } } else { - literal("Intervals are specified by @samp{\\@{} and @samp{\\@}}. "); + literal ("Intervals are specified by @samp{\\@{} and @samp{\\@}}. "); if (options & RE_INVALID_INTERVAL_ORD) { - literal("Invalid intervals are treated as literals, for example @samp{a\\@{1} is treated as @samp{a@{1}"); + literal ("Invalid intervals are treated as literals, for example @samp{a\\@{1} is treated as @samp{a@{1}"); } else { - literal("Invalid intervals such as @samp{a\\@{1z} are not accepted. "); + literal ("Invalid intervals such as @samp{a\\@{1z} are not accepted. "); } } } - newpara(); + newpara (); if (options & RE_NO_POSIX_BACKTRACKING) { - content("Matching succeeds as soon as the whole pattern is matched, meaning that the result may not be the longest possible match. "); + content ("Matching succeeds as soon as the whole pattern is matched, meaning that the result may not be the longest possible match. "); } else { - content("The longest possible match is returned; this applies to the regular expression as a whole and (subject to this constraint) to subexpressions within groups. "); + content ("The longest possible match is returned; this applies to the regular expression as a whole and (subject to this constraint) to subexpressions within groups. "); } - newpara(); + newpara (); } -static void copying(void) +static void copying (void) { static const char *copy_para[]= { @@ -452,50 +452,50 @@ static void copying(void) }; const char **s = copy_para; while (*s) - comment(*s++); + comment (*s++); } static int -ignore(int ix, const unsigned int context) +ignore (int ix, const unsigned int context) { - return 0 == (get_regex_type_context(ix) & context); + return 0 == (get_regex_type_context (ix) & context); } static void -menu(unsigned int context) +menu (unsigned int context) { int i, options; const char *name; - output("@menu\n", 0); + output ("@menu\n", 0); for (i=0; - options = get_regex_type_flags(i), - name=get_regex_type_name(i); + options = get_regex_type_flags (i), + name=get_regex_type_name (i); ++i) { - if (!ignore(i, context)) + if (!ignore (i, context)) { - output("* ", 0); - output(name, 0); - content(" regular expression syntax"); - output("::", 0); - newline(); + output ("* ", 0); + output (name, 0); + content (" regular expression syntax"); + output ("::", 0); + newline (); } } - output("@end menu\n", 0); + output ("@end menu\n", 0); } static const char * -get_next(unsigned int ix, unsigned int context) +get_next (unsigned int ix, unsigned int context) { const char *next; - while (get_regex_type_name(ix)) + while (get_regex_type_name (ix)) { - if (!ignore(ix, context)) + if (!ignore (ix, context)) { - next = get_regex_type_name(ix); + next = get_regex_type_name (ix); if (NULL == next) return ""; else @@ -508,52 +508,52 @@ get_next(unsigned int ix, unsigned int context) static void -describe_all(const char *contextname, - unsigned int context, - const char *up) +describe_all (const char *contextname, + unsigned int context, + const char *up) { const char *name, *next, *previous; int options; int i, parent; - copying(); - newline(); - literal("@c this regular expression description is for: "); - literal(contextname); - newline(); - newline(); - menu(context); + copying (); + newline (); + literal ("@c this regular expression description is for: "); + literal (contextname); + newline (); + newline (); + menu (context); previous = ""; for (i=0; - options = get_regex_type_flags(i), - name=get_regex_type_name(i); + options = get_regex_type_flags (i), + name=get_regex_type_name (i); ++i) { - if (ignore(i, context)) + if (ignore (i, context)) { - fprintf(stderr, - "Skipping regexp type %s for context %s\n", - name, contextname); + fprintf (stderr, + "Skipping regexp type %s for context %s\n", + name, contextname); name = previous; continue; } - next = get_next(i+1, context); + next = get_next (i+1, context); if (NULL == next) next = ""; - begin_subsection(name, next, previous, up); - parent = get_regex_type_synonym(i); + begin_subsection (name, next, previous, up); + parent = get_regex_type_synonym (i); if (parent >= 0) { - content("This is a synonym for "); - content(get_regex_type_name(parent)); - content("."); + content ("This is a synonym for "); + content (get_regex_type_name (parent)); + content ("."); } else { - describe_regex_syntax(options); + describe_regex_syntax (options); } previous = name; } @@ -575,20 +575,20 @@ int main (int argc, char *argv[]) if (argc > 2) { contextname = argv[2]; - if (0 == strcmp(contextname, "findutils")) + if (0 == strcmp (contextname, "findutils")) context = CONTEXT_FINDUTILS; - else if (0 == strcmp(contextname, "generic")) + else if (0 == strcmp (contextname, "generic")) context = CONTEXT_GENERIC; - else if (0 == strcmp(contextname, "all")) + else if (0 == strcmp (contextname, "all")) context = CONTEXT_ALL; else { - fprintf(stderr, "Unexpected context %s", - contextname); + fprintf (stderr, "Unexpected context %s", + contextname); return 1; } } - describe_all(contextname, context, up); + describe_all (contextname, context, up); return 0; } diff --git a/lib/regextype.c b/lib/regextype.c index 9be09646..1253d5ae 100644 --- a/lib/regextype.c +++ b/lib/regextype.c @@ -2,7 +2,7 @@ /* regextype.c -- Decode the name of a regular expression syntax into am option name. - Copyright 2005 Free Software Foundation, Inc. + Copyright 2005, 2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -71,10 +71,10 @@ struct tagRegexTypeMap regex_map[] = { "sed", CONTEXT_GENERIC, RE_SYNTAX_SED }, /* ,{ "posix-common", CONTEXT_GENERIC, _RE_SYNTAX_POSIX_COMMON } */ }; -enum { N_REGEX_MAP_ENTRIES = sizeof(regex_map)/sizeof(regex_map[0]) }; +enum { N_REGEX_MAP_ENTRIES = sizeof (regex_map)/sizeof (regex_map[0]) }; int -get_regex_type(const char *s) +get_regex_type (const char *s) { unsigned i; size_t msglen; @@ -83,28 +83,28 @@ get_regex_type(const char *s) msglen = 0u; for (i=0u; i 0u) { - strcpy(p, ", "); + strcpy (p, ", "); p += 2; } - p += sprintf(p, "%s", quote(regex_map[i].name)); + p += sprintf (p, "%s", quote (regex_map[i].name)); } - error(1, 0, _("Unknown regular expression type %s; valid types are %s."), - quote(s), + error (1, 0, _("Unknown regular expression type %s; valid types are %s."), + quote (s), buf); /*NOTREACHED*/ return -1; @@ -112,7 +112,7 @@ get_regex_type(const char *s) const char * -get_regex_type_name(unsigned int ix) +get_regex_type_name (unsigned int ix) { if (ix < N_REGEX_MAP_ENTRIES) return regex_map[ix].name; @@ -121,7 +121,7 @@ get_regex_type_name(unsigned int ix) } int -get_regex_type_flags(unsigned int ix) +get_regex_type_flags (unsigned int ix) { if (ix < N_REGEX_MAP_ENTRIES) return regex_map[ix].option_val; @@ -129,7 +129,7 @@ get_regex_type_flags(unsigned int ix) return -1; } -unsigned int get_regex_type_context(unsigned int ix) +unsigned int get_regex_type_context (unsigned int ix) { if (ix < N_REGEX_MAP_ENTRIES) return regex_map[ix].context; @@ -137,7 +137,7 @@ unsigned int get_regex_type_context(unsigned int ix) return 0u; } -int get_regex_type_synonym(unsigned int ix) +int get_regex_type_synonym (unsigned int ix) { unsigned i; int flags; diff --git a/lib/savedirinfo.c b/lib/savedirinfo.c index 61406810..631c0385 100644 --- a/lib/savedirinfo.c +++ b/lib/savedirinfo.c @@ -1,7 +1,7 @@ /* savedirinfo.c -- Save the list of files in a directory, with additional information. - Copyright 1990, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005 Free - Software Foundation, Inc. + Copyright 1990, 1997, 1998, 1999, 2000, 2001, 2003, 2004, + 2005, 2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -84,7 +84,7 @@ * if the type is DT_UNKNOWN or is a value we don't know about. */ static mode_t -type_to_mode(unsigned type) +type_to_mode (unsigned type) { switch (type) { @@ -126,18 +126,18 @@ struct new_savedir_direntry_internal static int -savedir_cmp(const void *p1, const void *p2) +savedir_cmp (const void *p1, const void *p2) { const struct savedir_direntry *de1, *de2; de1 = p1; de2 = p2; - return strcmp(de1->name, de2->name); /* POSIX order, not locale order. */ + return strcmp (de1->name, de2->name); /* POSIX order, not locale order. */ } static struct savedir_direntry* -convertentries(const struct savedir_dirinfo *info, - struct new_savedir_direntry_internal *internal) +convertentries (const struct savedir_dirinfo *info, + struct new_savedir_direntry_internal *internal) { char *p = info->buffer; struct savedir_direntry *result; @@ -145,7 +145,7 @@ convertentries(const struct savedir_dirinfo *info, int i; - result = xmalloc(sizeof(*result) * info->size); + result = xmalloc (sizeof (*result) * info->size); for (i=0; ibuffer = NULL; result->size = 0u; result->entries = NULL; @@ -189,15 +189,15 @@ xsavedir(const char *dir, int flags) { /* Remember the name. */ size_t entry_size = strlen (entry) + 1; - result->buffer = extendbuf(result->buffer, namebuf_used+entry_size, &namebuf_allocated); + result->buffer = extendbuf (result->buffer, namebuf_used+entry_size, &namebuf_allocated); memcpy ((result->buffer) + namebuf_used, entry, entry_size); /* Remember the other stuff. */ - internal = extendbuf(internal, (1+result->size)*sizeof(*internal), &entrybuf_allocated); + internal = extendbuf (internal, (1+result->size)*sizeof (*internal), &entrybuf_allocated); internal[result->size].flags = 0; #if defined HAVE_STRUCT_DIRENT_D_TYPE && defined USE_STRUCT_DIRENT_D_TYPE - internal[result->size].type_info = type_to_mode(dp->d_type); + internal[result->size].type_info = type_to_mode (dp->d_type); if (dp->d_type != DT_UNKNOWN) internal[result->size].flags |= SavedirHaveFileType; #else @@ -211,20 +211,20 @@ xsavedir(const char *dir, int flags) } } - result->buffer = extendbuf(result->buffer, namebuf_used+1, &namebuf_allocated); + result->buffer = extendbuf (result->buffer, namebuf_used+1, &namebuf_allocated); result->buffer[namebuf_used] = '\0'; /* convert the result to its externally-usable form. */ - result->entries = convertentries(result, internal); - free(internal); + result->entries = convertentries (result, internal); + free (internal); internal = NULL; if (flags & SavedirSort) { - qsort(result->entries, - result->size, sizeof(*result->entries), - savedir_cmp); + qsort (result->entries, + result->size, sizeof (*result->entries), + savedir_cmp); } @@ -242,13 +242,13 @@ xsavedir(const char *dir, int flags) return result; } -void free_dirinfo(struct savedir_dirinfo *p) +void free_dirinfo (struct savedir_dirinfo *p) { - free(p->entries); + free (p->entries); p->entries = NULL; - free(p->buffer); + free (p->buffer); p->buffer = NULL; - free(p); + free (p); } @@ -256,27 +256,27 @@ void free_dirinfo(struct savedir_dirinfo *p) static char * new_savedirinfo (const char *dir, struct savedir_extrainfo **extra) { - struct savedir_dirinfo *p = xsavedir(dir, SavedirSort); + struct savedir_dirinfo *p = xsavedir (dir, SavedirSort); char *buf, *s; size_t bufbytes = 0; unsigned int i; if (p) { - struct savedir_extrainfo *pex = xmalloc(p->size * sizeof(*extra)); + struct savedir_extrainfo *pex = xmalloc (p->size * sizeof (*extra)); for (i=0; isize; ++i) { - bufbytes += strlen(p->entries[i].name); + bufbytes += strlen (p->entries[i].name); ++bufbytes; /* the \0 */ pex[i].type_info = p->entries[i].type_info; } - s = buf = xmalloc(bufbytes+1); + s = buf = xmalloc (bufbytes+1); for (i=0; isize; ++i) { - size_t len = strlen(p->entries[i].name); - memcpy(s, p->entries[i].name, len); + size_t len = strlen (p->entries[i].name); + memcpy (s, p->entries[i].name, len); s += len; *s = 0; /* Place a NUL */ ++s; /* Skip the NUL. */ @@ -333,7 +333,7 @@ old_savedirinfo (const char *dir, struct savedir_extrainfo **extra) { /* Remember the name. */ size_t entry_size = strlen (entry) + 1; - name_space = extendbuf(name_space, namebuf_used+entry_size, &namebuf_allocated); + name_space = extendbuf (name_space, namebuf_used+entry_size, &namebuf_allocated); memcpy (name_space + namebuf_used, entry, entry_size); namebuf_used += entry_size; @@ -342,17 +342,17 @@ old_savedirinfo (const char *dir, struct savedir_extrainfo **extra) /* Remember the type. */ if (extra) { - info = extendbuf(info, - (extra_used+1) * sizeof(struct savedir_dirinfo), - &extra_allocated); - info[extra_used].type_info = type_to_mode(dp->d_type); + info = extendbuf (info, + (extra_used+1) * sizeof (struct savedir_dirinfo), + &extra_allocated); + info[extra_used].type_info = type_to_mode (dp->d_type); ++extra_used; } #endif } } - name_space = extendbuf(name_space, namebuf_used+1, &namebuf_allocated); + name_space = extendbuf (name_space, namebuf_used+1, &namebuf_allocated); name_space[namebuf_used] = '\0'; save_errno = errno; @@ -378,5 +378,5 @@ old_savedirinfo (const char *dir, struct savedir_extrainfo **extra) char * savedirinfo (const char *dir, struct savedir_extrainfo **extra) { - return new_savedirinfo(dir, extra); + return new_savedirinfo (dir, extra); }