diff options
author | Joseph Myers <joseph@codesourcery.com> | 2019-02-22 01:32:36 +0000 |
---|---|---|
committer | Joseph Myers <joseph@codesourcery.com> | 2019-02-22 01:32:36 +0000 |
commit | 34a5a1460e9c05d6035bfbde327ab6d45f78958b (patch) | |
tree | 2b607b87a53dd463fe92bf291895af86060b792f /posix | |
parent | nss: tst-nss-files-hosts-long: Add host.conf [BZ #21915] (diff) | |
download | glibc-34a5a1460e9c05d6035bfbde327ab6d45f78958b.tar.gz glibc-34a5a1460e9c05d6035bfbde327ab6d45f78958b.tar.bz2 glibc-34a5a1460e9c05d6035bfbde327ab6d45f78958b.zip |
Break some lines before not after operators.
The GNU Coding Standards specify that line breaks in expressions
should go before an operator, not after one. This patch fixes various
code to do this. It only changes code that appears to be mostly
following GNU style anyway, not files and directories with
substantially different formatting. It is not exhaustive even for
files using GNU style (for example, changes to sysdeps files are
deferred for subsequent cleanups). Some files changed are shared with
gnulib, but most are specific to glibc. Changes were made manually,
with places to change found by grep (so some cases, e.g. where the
operator was followed by a comment at end of line, are particularly
liable to have been missed by grep, but I did include cases where the
operator was followed by backslash-newline).
This patch generally does not attempt to address other coding style
issues in the expressions changed (for example, missing spaces before
'(', or lack of parentheses to ensure indentation of continuation
lines properly reflects operator precedence).
Tested for x86_64, and with build-many-glibcs.py.
* benchtests/bench-memmem.c (simple_memmem): Break lines before
rather than after operators.
* benchtests/bench-skeleton.c (TIMESPEC_AFTER): Likewise.
* crypt/md5.c (md5_finish_ctx): Likewise.
* crypt/sha256.c (__sha256_finish_ctx): Likewise.
* crypt/sha512.c (__sha512_finish_ctx): Likewise.
* elf/cache.c (load_aux_cache): Likewise.
* elf/dl-load.c (open_verify): Likewise.
* elf/get-dynamic-info.h (elf_get_dynamic_info): Likewise.
* elf/readelflib.c (process_elf_file): Likewise.
* elf/rtld.c (dl_main): Likewise.
* elf/sprof.c (generate_call_graph): Likewise.
* hurd/ctty-input.c (_hurd_ctty_input): Likewise.
* hurd/ctty-output.c (_hurd_ctty_output): Likewise.
* hurd/dtable.c (reauth_dtable): Likewise.
* hurd/getdport.c (__getdport): Likewise.
* hurd/hurd/signal.h (_hurd_interrupted_rpc_timeout): Likewise.
* hurd/hurd/sigpreempt.h (HURD_PREEMPT_SIGNAL_P): Likewise.
* hurd/hurdfault.c (_hurdsig_fault_catch_exception_raise):
Likewise.
* hurd/hurdioctl.c (fioctl): Likewise.
* hurd/hurdselect.c (_hurd_select): Likewise.
* hurd/hurdsig.c (_hurdsig_abort_rpcs): Likewise.
(STOPSIGS): Likewise.
* hurd/hurdstartup.c (_hurd_startup): Likewise.
* hurd/intr-msg.c (_hurd_intr_rpc_mach_msg): Likewise.
* hurd/lookup-retry.c (__hurd_file_name_lookup_retry): Likewise.
* hurd/msgportdemux.c (msgport_server): Likewise.
* hurd/setauth.c (_hurd_setauth): Likewise.
* include/features.h (__GLIBC_USE_DEPRECATED_SCANF): Likewise.
* libio/libioP.h [IO_DEBUG] (CHECK_FILE): Likewise.
* locale/programs/ld-ctype.c (set_class_defaults): Likewise.
* localedata/tests-mbwc/tst_swscanf.c (tst_swscanf): Likewise.
* login/tst-utmp.c (do_check): Likewise.
(simulate_login): Likewise.
* mach/lowlevellock.h (lll_lock): Likewise.
(lll_trylock): Likewise.
* math/test-fenv.c (ALL_EXC): Likewise.
* math/test-fenvinline.c (ALL_EXC): Likewise.
* misc/sys/cdefs.h (__attribute_deprecated_msg__): Likewise.
* nis/nis_call.c (__do_niscall3): Likewise.
* nis/nis_callback.c (cb_prog_1): Likewise.
* nis/nis_defaults.c (searchaccess): Likewise.
* nis/nis_findserv.c (__nis_findfastest_with_timeout): Likewise.
* nis/nis_ismember.c (internal_ismember): Likewise.
* nis/nis_local_names.c (nis_local_principal): Likewise.
* nis/nss_nis/nis-rpc.c (_nss_nis_getrpcbyname_r): Likewise.
* nis/nss_nisplus/nisplus-netgrp.c (_nss_nisplus_getnetgrent_r):
Likewise.
* nis/ypclnt.c (yp_match): Likewise.
(yp_first): Likewise.
(yp_next): Likewise.
(yp_master): Likewise.
(yp_order): Likewise.
* nscd/hstcache.c (cache_addhst): Likewise.
* nscd/initgrcache.c (addinitgroupsX): Likewise.
* nss/nss_compat/compat-pwd.c (copy_pwd_changes): Likewise.
(internal_getpwuid_r): Likewise.
* nss/nss_compat/compat-spwd.c (copy_spwd_changes): Likewise.
* posix/glob.h (__GLOB_FLAGS): Likewise.
* posix/regcomp.c (peek_token): Likewise.
(peek_token_bracket): Likewise.
(parse_expression): Likewise.
* posix/regexec.c (sift_states_iter_mb): Likewise.
(check_node_accept_bytes): Likewise.
* posix/tst-spawn3.c (do_test): Likewise.
* posix/wordexp-test.c (testit): Likewise.
* posix/wordexp.c (parse_tilde): Likewise.
(exec_comm): Likewise.
* posix/wordexp.h (__WRDE_FLAGS): Likewise.
* resource/vtimes.c (TIMEVAL_TO_VTIMES): Likewise.
* setjmp/sigjmp.c (__sigjmp_save): Likewise.
* stdio-common/printf_fp.c (__printf_fp_l): Likewise.
* stdio-common/tst-fileno.c (do_test): Likewise.
* stdio-common/vfprintf-internal.c (vfprintf): Likewise.
* stdlib/strfmon_l.c (__vstrfmon_l_internal): Likewise.
* stdlib/strtod_l.c (round_and_return): Likewise.
(____STRTOF_INTERNAL): Likewise.
* stdlib/tst-strfrom.h (TEST_STRFROM): Likewise.
* string/strcspn.c (STRCSPN): Likewise.
* string/test-memmem.c (simple_memmem): Likewise.
* termios/tcsetattr.c (tcsetattr): Likewise.
* time/alt_digit.c (_nl_parse_alt_digit): Likewise.
* time/asctime.c (asctime_internal): Likewise.
* time/strptime_l.c (__strptime_internal): Likewise.
* time/sys/time.h (timercmp): Likewise.
* time/tzfile.c (__tzfile_compute): Likewise.
Diffstat (limited to 'posix')
-rw-r--r-- | posix/glob.h | 14 | ||||
-rw-r--r-- | posix/regcomp.c | 20 | ||||
-rw-r--r-- | posix/regexec.c | 14 | ||||
-rw-r--r-- | posix/tst-spawn3.c | 4 | ||||
-rw-r--r-- | posix/wordexp-test.c | 12 | ||||
-rw-r--r-- | posix/wordexp.c | 8 | ||||
-rw-r--r-- | posix/wordexp.h | 4 |
7 files changed, 38 insertions, 38 deletions
diff --git a/posix/glob.h b/posix/glob.h index a5f3fe15d3..378b80af8f 100644 --- a/posix/glob.h +++ b/posix/glob.h @@ -54,14 +54,14 @@ typedef __SIZE_TYPE__ size_t; # define GLOB_ONLYDIR (1 << 13)/* Match only directories. */ # define GLOB_TILDE_CHECK (1 << 14)/* Like GLOB_TILDE but return an error if the user name is not available. */ -# define __GLOB_FLAGS (GLOB_ERR|GLOB_MARK|GLOB_NOSORT|GLOB_DOOFFS| \ - GLOB_NOESCAPE|GLOB_NOCHECK|GLOB_APPEND| \ - GLOB_PERIOD|GLOB_ALTDIRFUNC|GLOB_BRACE| \ - GLOB_NOMAGIC|GLOB_TILDE|GLOB_ONLYDIR|GLOB_TILDE_CHECK) +# define __GLOB_FLAGS (GLOB_ERR|GLOB_MARK|GLOB_NOSORT|GLOB_DOOFFS \ + |GLOB_NOESCAPE|GLOB_NOCHECK|GLOB_APPEND \ + |GLOB_PERIOD|GLOB_ALTDIRFUNC|GLOB_BRACE \ + |GLOB_NOMAGIC|GLOB_TILDE|GLOB_ONLYDIR|GLOB_TILDE_CHECK) #else -# define __GLOB_FLAGS (GLOB_ERR|GLOB_MARK|GLOB_NOSORT|GLOB_DOOFFS| \ - GLOB_NOESCAPE|GLOB_NOCHECK|GLOB_APPEND| \ - GLOB_PERIOD) +# define __GLOB_FLAGS (GLOB_ERR|GLOB_MARK|GLOB_NOSORT|GLOB_DOOFFS \ + |GLOB_NOESCAPE|GLOB_NOCHECK|GLOB_APPEND \ + |GLOB_PERIOD) #endif /* Error returns from `glob'. */ diff --git a/posix/regcomp.c b/posix/regcomp.c index cc85f35ac5..7525355a9b 100644 --- a/posix/regcomp.c +++ b/posix/regcomp.c @@ -1800,8 +1800,8 @@ peek_token (re_token_t *token, re_string_t *input, reg_syntax_t syntax) token->word_char = 0; #ifdef RE_ENABLE_I18N token->mb_partial = 0; - if (input->mb_cur_max > 1 && - !re_string_first_byte (input, re_string_cur_idx (input))) + if (input->mb_cur_max > 1 + && !re_string_first_byte (input, re_string_cur_idx (input))) { token->type = CHARACTER; token->mb_partial = 1; @@ -1988,8 +1988,8 @@ peek_token (re_token_t *token, re_string_t *input, reg_syntax_t syntax) token->type = OP_PERIOD; break; case '^': - if (!(syntax & (RE_CONTEXT_INDEP_ANCHORS | RE_CARET_ANCHORS_HERE)) && - re_string_cur_idx (input) != 0) + if (!(syntax & (RE_CONTEXT_INDEP_ANCHORS | RE_CARET_ANCHORS_HERE)) + && re_string_cur_idx (input) != 0) { char prev = re_string_peek_byte (input, -1); if (!(syntax & RE_NEWLINE_ALT) || prev != '\n') @@ -1999,8 +1999,8 @@ peek_token (re_token_t *token, re_string_t *input, reg_syntax_t syntax) token->opr.ctx_type = LINE_FIRST; break; case '$': - if (!(syntax & RE_CONTEXT_INDEP_ANCHORS) && - re_string_cur_idx (input) + 1 != re_string_length (input)) + if (!(syntax & RE_CONTEXT_INDEP_ANCHORS) + && re_string_cur_idx (input) + 1 != re_string_length (input)) { re_token_t next; re_string_skip_bytes (input, 1); @@ -2034,8 +2034,8 @@ peek_token_bracket (re_token_t *token, re_string_t *input, reg_syntax_t syntax) token->opr.c = c; #ifdef RE_ENABLE_I18N - if (input->mb_cur_max > 1 && - !re_string_first_byte (input, re_string_cur_idx (input))) + if (input->mb_cur_max > 1 + && !re_string_first_byte (input, re_string_cur_idx (input))) { token->type = CHARACTER; return 1; @@ -2333,8 +2333,8 @@ parse_expression (re_string_t *regexp, regex_t *preg, re_token_t *token, } FALLTHROUGH; case OP_CLOSE_SUBEXP: - if ((token->type == OP_CLOSE_SUBEXP) && - !(syntax & RE_UNMATCHED_RIGHT_PAREN_ORD)) + if ((token->type == OP_CLOSE_SUBEXP) + && !(syntax & RE_UNMATCHED_RIGHT_PAREN_ORD)) { *err = REG_ERPAREN; return NULL; diff --git a/posix/regexec.c b/posix/regexec.c index 084b1222d9..4ff30a79c0 100644 --- a/posix/regexec.c +++ b/posix/regexec.c @@ -2204,9 +2204,9 @@ sift_states_iter_mb (const re_match_context_t *mctx, re_sift_context_t *sctx, int naccepted; /* Check the node can accept "multi byte". */ naccepted = check_node_accept_bytes (dfa, node_idx, &mctx->input, str_idx); - if (naccepted > 0 && str_idx + naccepted <= max_str_idx && - !STATE_NODE_CONTAINS (sctx->sifted_states[str_idx + naccepted], - dfa->nexts[node_idx])) + if (naccepted > 0 && str_idx + naccepted <= max_str_idx + && !STATE_NODE_CONTAINS (sctx->sifted_states[str_idx + naccepted], + dfa->nexts[node_idx])) /* The node can't accept the "multi byte", or the destination was already thrown away, then the node couldn't accept the current input "multi byte". */ @@ -3782,10 +3782,10 @@ check_node_accept_bytes (const re_dfa_t *dfa, Idx node_idx, /* FIXME: I don't think this if is needed, as both '\n' and '\0' are char_len == 1. */ /* '.' accepts any one character except the following two cases. */ - if ((!(dfa->syntax & RE_DOT_NEWLINE) && - re_string_byte_at (input, str_idx) == '\n') || - ((dfa->syntax & RE_DOT_NOT_NULL) && - re_string_byte_at (input, str_idx) == '\0')) + if ((!(dfa->syntax & RE_DOT_NEWLINE) + && re_string_byte_at (input, str_idx) == '\n') + || ((dfa->syntax & RE_DOT_NOT_NULL) + && re_string_byte_at (input, str_idx) == '\0')) return 0; return char_len; } diff --git a/posix/tst-spawn3.c b/posix/tst-spawn3.c index 8dae1414f9..00c9470ba5 100644 --- a/posix/tst-spawn3.c +++ b/posix/tst-spawn3.c @@ -84,8 +84,8 @@ do_test (void) /* Executes a /bin/sh echo $$ 2>&1 > ${objpfx}tst-spawn3.pid . */ const char pidfile[] = OBJPFX "tst-spawn3.pid"; - if (posix_spawn_file_actions_addopen (&a, STDOUT_FILENO, pidfile, O_WRONLY | - O_CREAT | O_TRUNC, 0644) != 0) + if (posix_spawn_file_actions_addopen (&a, STDOUT_FILENO, pidfile, O_WRONLY + | O_CREAT | O_TRUNC, 0644) != 0) FAIL_EXIT1 ("posix_spawn_file_actions_addopen"); if (posix_spawn_file_actions_adddup2 (&a, STDOUT_FILENO, STDERR_FILENO) != 0) diff --git a/posix/wordexp-test.c b/posix/wordexp-test.c index 0f2da81f33..10a0768a6b 100644 --- a/posix/wordexp-test.c +++ b/posix/wordexp-test.c @@ -508,8 +508,8 @@ testit (struct test_case_struct *tc) } for (i = 0; i < we.we_wordc; ++i) - if (we.we_wordv[i+start_offs] == NULL || - strcmp (tc->wordv[i], we.we_wordv[i+start_offs]) != 0) + if (we.we_wordv[i+start_offs] == NULL + || strcmp (tc->wordv[i], we.we_wordv[i+start_offs]) != 0) { bzzzt = 1; break; @@ -534,10 +534,10 @@ testit (struct test_case_struct *tc) } printf ("\n"); } - else if (retval != 0 && retval != WRDE_NOSPACE && - (we.we_wordc != sav_we.we_wordc || - we.we_wordv != sav_we.we_wordv || - we.we_offs != sav_we.we_offs)) + else if (retval != 0 && retval != WRDE_NOSPACE + && (we.we_wordc != sav_we.we_wordc + || we.we_wordv != sav_we.we_wordv + || we.we_offs != sav_we.we_offs)) { bzzzt = 1; printf ("FAILED to restore wordexp_t members\n"); diff --git a/posix/wordexp.c b/posix/wordexp.c index 248de77fba..22c6d18a9c 100644 --- a/posix/wordexp.c +++ b/posix/wordexp.c @@ -285,8 +285,8 @@ parse_tilde (char **word, size_t *word_length, size_t *max_length, for (i = 1 + *offset; words[i]; i++) { - if (words[i] == ':' || words[i] == '/' || words[i] == ' ' || - words[i] == '\t' || words[i] == 0 ) + if (words[i] == ':' || words[i] == '/' || words[i] == ' ' + || words[i] == '\t' || words[i] == 0 ) break; if (words[i] == '\\') @@ -1070,8 +1070,8 @@ exec_comm (char *comm, char **word, size_t *word_length, size_t *max_length, /* Chop off trailing newlines (required by POSIX.2) */ /* Ensure we don't go back further than the beginning of the substitution (i.e. remove maxnewlines bytes at most) */ - while (maxnewlines-- != 0 && - *word_length > 0 && (*word)[*word_length - 1] == '\n') + while (maxnewlines-- != 0 + && *word_length > 0 && (*word)[*word_length - 1] == '\n') { (*word)[--*word_length] = '\0'; diff --git a/posix/wordexp.h b/posix/wordexp.h index 148b9e1e70..060f13fe49 100644 --- a/posix/wordexp.h +++ b/posix/wordexp.h @@ -33,8 +33,8 @@ enum WRDE_REUSE = (1 << 3), /* Reuse storage in PWORDEXP. */ WRDE_SHOWERR = (1 << 4), /* Don't redirect stderr to /dev/null. */ WRDE_UNDEF = (1 << 5), /* Error for expanding undefined variables. */ - __WRDE_FLAGS = (WRDE_DOOFFS | WRDE_APPEND | WRDE_NOCMD | - WRDE_REUSE | WRDE_SHOWERR | WRDE_UNDEF) + __WRDE_FLAGS = (WRDE_DOOFFS | WRDE_APPEND | WRDE_NOCMD + | WRDE_REUSE | WRDE_SHOWERR | WRDE_UNDEF) }; /* Structure describing a word-expansion run. */ |