1
0
mirror of https://https.git.savannah.gnu.org/git/gnulib.git synced 2026-09-01 02:34:55 +00:00

lib: Reduce scope of local variables.

M = Move variable declaration to its initialization.
R = Reduce scope.
S = Split scope, create separate variables from one variable.
B = Insert braces, creating a block scope.
O = Change order of initializations.

* lib/accept4.c (accept4): M.
* lib/acl-internal.c (acl_ace_nontrivial): R.
* lib/acosl.c (acosl): MS.
* lib/af_alg.c (afalg_stream): B.
* lib/alignalloc.h (alignalloc): R.
* lib/alloca.c (find_stack_direction): M.
(alloca): M.
* lib/amemxfrm.c (amemxfrm): MR.
* lib/arcfour.c (arcfour_stream): MB.
(arcfour_setkey): MB.
* lib/arctwo.c (arctwo_encrypt): M.
(arctwo_decrypt): M.
(arctwo_setkey_ekb): M.
* lib/areadlink-with-size.c (areadlink_with_size): MR.
* lib/areadlinkat-with-size.c (areadlinkat_with_size): MR.
* lib/argmatch.c (argmatch): MO.
(main): RBO.
* lib/argp-fmtstream.c (__argp_make_fmtstream): M.
(__argp_fmtstream_update): M.
(__argp_fmtstream_ensure): R.
(__argp_fmtstream_printf): R.
* lib/argp-fmtstream.h (__argp_fmtstream_set_lmargin): M.
(__argp_fmtstream_set_rmargin): M.
(__argp_fmtstream_set_wmargin): M.
* lib/argp-help.c (validate_uparams): M.
(fill_in_uparams): MR.
(make_hol): MRSO.
(hol_entry_short_iterate): R.
(hol_entry_long_iterate): R.
(hol_entry_first_long): Rename 'num' to 'nopts'.
(canon_doc_option): M.
(hol_append): MR.
(argp_hol): O.
(hol_entry_help): RSBO.
(hol_help): RB.
(usage_argful_short_opt): R.
(usage_long_opt): R.
(hol_usage): SB.
(argp_args_levels): R.
(argp_args_usage): MRB.
(argp_doc): RBO.
(_help): MR.
(__argp_error): R.
* lib/argp-parse.c (group_parse): M.
(parser_init): MRB.
(parser_finalize): MS.
(parser_parse_next): R.
(__argp_parse): MR.
(__argp_input): M.
* lib/argz.c (argz_add_sep): M.
(argz_create_sep): M.
(argz_create): R.
(argz_replace): RB.
* lib/asinl.c (asinl): MRS.
* lib/asnprintf.c (asnprintf): M.
* lib/asnwprintf.c (asnwprintf): M.
* lib/asprintf.c (asprintf): M.
* lib/astrxfrm.c (astrxfrm): MR.
* lib/aszprintf.c (aszprintf): M.
* lib/at-func.c (AT_FUNC_NAME): MR.
* lib/at-func2.c (at_func2): MRS.
* lib/atanl.c (atanl): MRS.
* lib/backupfile.c (numbered_backup): R.
* lib/base32.c (decode_8): R.
(base32_decode_ctx): R.
* lib/base64.c (decode_4): R.
(base64_decode_ctx): R.
* lib/basename-lgpl.c (last_component): R.
(base_len): RO.
* lib/bitset.c (bitset_copy_): R.
* lib/bitset/list.c (lbitset_prune): MR.
(lbitset_weed): MR.
(lbitset_list): SB.
* lib/bitset/table.c (tbitset_list): SB.
* lib/boot-time-aux.h (get_windows_boot_time_fallback): R.
* lib/btoc32.c (btoc32): R.
* lib/c-asprintf.c (c_asprintf): M.
* lib/c-aszprintf.c (c_aszprintf): M.
* lib/c-snprintf.c (c_snprintf): M.
* lib/c-snzprintf.c (c_snzprintf): M.
* lib/c-strcasecmp.c (c_strcasecmp): R.
* lib/c-strcasestr.c (c_strcasestr): MRSB.
* lib/c-strncasecmp.c (c_strncasecmp): R.
* lib/c-strtod.c (C_STRTOD): R.
* lib/c-vsnzprintf.c (c_vsnzprintf): M.
* lib/c-xasprintf.c (c_xasprintf): M.
* lib/c32tob.c (c32tob): R.
* lib/canon-host.c (canon_host_r): MR.
* lib/canonicalize.c (canonicalize_filename_mode_stk): R.
* lib/canonicalize-lgpl.c (realpath_stk): R.
* lib/cbrt.c (cbrt): M.
* lib/cbrtf.c (cbrtf): M.
* lib/cbrtl.c (cbrtl): MR.
* lib/chdir-long.c (chdir_long): M.
(main): MR.
* lib/classpath.c (new_classpath): MB.
* lib/clean-temp.c (create_temp_dir): M.
(unregister_temp_file): M.
(unregister_temp_subdir): M.
(cleanup_temp_file): M.
(cleanup_temp_subdir): M.
(cleanup_temp_dir_contents): MSB.
(open_temp): R.
(fopen_temp): R.
(close_temp): RB.
(fclose_variant_temp): RB.
* lib/clean-temp-simple.c (cleanup_action): MSB.
(cleanup_temporary_file): M.
* lib/copy-file.c (copy_file_internal): MRB.
* lib/cosl.c (cosl): MR.
* lib/crc-generate-table.c (make_crc_table): M.
* lib/crc-x86_64-pclmul.c (crc32_update_no_xor_pclmul): MRSB.
* lib/crc.c (crc32_update_no_xor_slice_by_8): S.
(crc32_update_no_xor_slice_by_n): M.
(crc32_update_no_xor): MR.
* lib/csharpcomp.c (compile_csharp_using_mono): MRB.
(compile_csharp_using_dotnet): MRSB.
(compile_csharp_using_sscli): MRB.
* lib/csharpexec.c (execute_csharp_using_mono): MO.
(execute_csharp_using_dotnet): MO.
(execute_csharp_using_sscli): MO.
(execute_csharp_program): R.
* lib/cygpath.c (execute_and_read_line): M.
* lib/des.c (gl_des_is_weak_key): M.
(gl_3des_ecb_crypt): MO.
* lib/dfa.c (closure): B.
(dfamust): MRB.
* lib/di-set.c (map_device): M.
(di_set_insert): M.
(di_set_lookup): M.
* lib/dirname-lgpl.c (dir_len): R.
* lib/dprintf.c (dprintf): M.
* lib/dup.c (dup_nothrow): R.
* lib/dup2.c (ms_windows_dup2): M.
(klibc_dup2dirfd): M.
(klibc_dup2): MR.
(rpl_dup2): M.
* lib/dup3.c (dup3): M.
* lib/duplocale.c (duplocale): MRSB.
* lib/dzprintf.c (dzprintf): M.
* lib/euidaccess.c (euidaccess): MR.
(main): M.
* lib/exclude.c (add_exclude): R.
* lib/execl.c (execl): SB.
* lib/execle.c (execle): SB.
* lib/execlp.c (execlp): SB.
* lib/execute.c (execute): R.
* lib/fchdir.c (ensure_dirs_slot): M.
(get_name): M.
(_gl_register_fd): R.
* lib/fclose.c (rpl_fclose): MR.
* lib/fcntl.c (dupfd): RO.
(fcntl): R.
(klibc_dupdirfd): M.
(klibc_fcntl): MRSB.
* lib/fdopen.c (rpl_fdopen): M.
* lib/file-has-acl.c (get_aclinfo): R.
(fdfile_has_aclinfo): MR.
* lib/file-remote.c (main): M.
* lib/file-set.c (record_file): M.
(seen_file): R.
* lib/findprog.c (find_in_path): MR.
* lib/findprog-in.c (find_in_given_path): MR.
* lib/flock.c (do_lock): MR.
(do_unlock): M.
(flock): MR.
* lib/fma.c (decode): M.
* lib/fopen.c (rpl_fopen): MR.
* lib/forkpty.c (forkpty): M.
* lib/fprintf.c (fprintf): M.
* lib/freadseek.c (freadseek): MR.
* lib/freopen.c (rpl_freopen): M.
* lib/freopen-safer.c (freopen_safer): M.
* lib/frexp.c (FUNC): MR.
* lib/fseterr.c (fseterr): M.
* lib/fstatat.c (rpl_fstatat): M.
* lib/fstrcmp.c (fstrcmp_free_resources): M.
(fstrcmp_bounded): MR.
* lib/fsusage.c (statvfs_works): R.
* lib/fsync.c (fsync): M.
* lib/ftello.c (ftello): M.
* lib/ftruncate.c (SetFileSize): M.
* lib/fts.c (fts_open): MR.
(fts_load): M.
(fts_close): MR.
(filesystem_type): MRO.
(fts_read): MB.
(fts_children): M.
(fts_build): MR.
(fts_cross_check): RO.
(fd_ring_print): RO.
(fts_stat): RO.
(fts_sort): R.
(fts_alloc): M.
(fts_lfree): R.
(fts_palloc): M.
(fts_padjust): MS.
(fts_maxarglen): M.
(fts_safe_changedir): MR.
* lib/fts-cycle.c (enter_dir): MRO.
(leave_dir): M.
* lib/fzprintf.c (fzprintf): M.
* lib/gc-gnulib.c (gc_cipher_open): MR.
(gc_cipher_setkey): MSB.
(gc_cipher_setiv): M.
(gc_cipher_encrypt_inline): M.
(gc_cipher_decrypt_inline): M.
(gc_hash_open): MR.
(gc_hash_clone): M.
* lib/gc-libgcrypt.c (gc_init): Remove local variable 'err'.
(gc_cipher_open): MR.
(gc_cipher_setkey): M.
(gc_cipher_setiv): M.
(gc_hash_open): MR.
(gc_hash_clone): M.
(gc_md4): MR.
(gc_md5): MR.
(gc_sha1): MR.
(gc_sha256): MR.
(gc_sha512): MR.
(gc_sm3): MR.
(gc_hmac_md5): MR. Remove local variable 'err'.
(gc_hmac_sha1): MR. Remove local variable 'err'.
(gc_hmac_sha256): MR. Remove local variable 'err'.
(gc_hmac_sha512): MR. Remove local variable 'err'.
* lib/gc-pbkdf2.c (gc_pbkdf2_prf): MR.
* lib/gen-uni-tables.c (fill_attributes): M.
(debug_output_predicate): M.
(output_predicate_test): M.
(output_predicate): MR.
(output_category): MR.
(output_combclass): MR.
(output_bidi_category): MR.
(output_decimal_digit_test): M.
(output_decimal_digit): MR.
(output_digit_test): M.
(output_digit): MR.
(output_numeric_test): M.
(output_numeric): MR.
(fill_mirror): MR.
(get_mirror_value): M.
(output_mirror): MR.
(fill_properties): MR.
(fill_property30): MR.
(output_indic_conjunct_break_test): M.
(output_indic_conjunct_break): MR.
(fill_arabicshaping): MR.
(output_joining_type_test): M.
(output_joining_type): MR.
(output_joining_group_test): M.
(output_joining_group): MR.
(fill_scripts): MR.
(output_scripts): MR.
(output_scripts_byname): M.
(fill_blocks): MR.
(output_blocks): M.
(output_ident_category): MR.
(output_charclass): MR.
(output_charmap): MR.
(output_tables): M.
(fill_width): MR.
(output_nonspacing_property): MR.
(output_width_property_test): M.
(debug_output_lbrk_tables): M.
(fill_org_lbp): MR.
(debug_output_org_lbrk_tables): M.
(output_lbpea): M.
(output_lbrk_tables): R.
(output_lbrk_rules_as_tables): M.
(debug_output_wbrk_tables): M.
(fill_org_wbp): MR.
(debug_output_org_wbrk_tables): M.
(output_wbp): M.
(output_wbrk_tables): M.
(output_gbp_test): MR.
(output_gbp_table): MR.
(fill_org_gbp): MR.
(get_decomposition): MR.
(output_decomposition): M.
(output_decomposition_tables): R.
(fill_composition_exclusions): MR.
(debug_output_composition_tables): M.
(output_composition_tables): MSB.
(output_simple_mapping_test): M.
(output_simple_mapping): MR.
(fill_casing_rules): MR.
(fill_casefolding_rules): MR.
(output_casing_rules): M.
(output_version): MR.
* lib/get-rusage-as.c (get_rusage_as_via_setrlimit): R.
(get_rusage_as): M.
* lib/get-rusage-data.c (get_rusage_data_via_setrlimit): R.
(get_rusage_data): M.
* lib/get_ppid_of.c (get_ppid_of): M.
* lib/get_progname_of.c (get_progname_of): MR.
* lib/getaddrinfo.c (use_win32_p): M.
(getaddrinfo): MR.
(freeaddrinfo): M.
* lib/getcwd.c (__getcwd_generic): MRSBO.
* lib/getcwd-lgpl.c (rpl_getcwd): MS.
* lib/getdelim.c (getdelim): MR.
* lib/getdomainname.c (getdomainname): M.
* lib/getentropy.c (getentropy): R.
* lib/getgroups.c (rpl_getgroups): MR.
* lib/gethostname.c (rpl_gethostname): M.
* lib/getloadavg.c (getloadavg): MRB.
* lib/getlocalename_l-unsafe.c (newlocale): MR.
(duplocale): MR.
(freelocale): M.
* lib/getlogin_r.c (getlogin_r): M.
* lib/getndelim2.c (getndelim2): MR.
* lib/getopt.c (exchange): MS.
(process_long_option): MRB.
(_getopt_internal_r): MR.
(_getopt_internal): M.
(main): M.
* lib/getopt1.c (main): M.
* lib/getpass.c (getpass): MRB.
* lib/getprogname.c (getprogname): M.
* lib/getrusage.c (getrusage): M.
* lib/getsockopt.c (rpl_getsockopt): M.
* lib/getsubopt.c (getsubopt): M.
* lib/gettext.h (dcpgettext_expr): M.
(dcnpgettext_expr): M.
* lib/gettimeofday.c (gettimeofday): R.
* lib/getugroups.c (getugroups): MR.
* lib/getumask.c (getumask): R.
* lib/gl_anyavltree_list2.h (rebalance): MR.
(gl_tree_remove_node_from_tree): MR.
(gl_tree_nx_add_before): R.
(gl_tree_nx_add_after): R.
* lib/gl_anyhash2.h (hash_resize): M.
* lib/gl_anylinked_list2.h (gl_linked_get_at): R.
(gl_linked_nx_set_at): R.
(gl_linked_search_from_to): R.
(gl_linked_indexof_from_to): MR.
(gl_linked_nx_add_at): M.
(gl_linked_remove_node): M.
(gl_linked_remove_at): MR.
(gl_linked_iterator_from_to): M.
(gl_linked_sortedlist_search_from_to): R.
(gl_linked_sortedlist_indexof_from_to): R.
* lib/gl_anyrbtree_list2.h (rebalance_after_add): MR.
(gl_tree_remove_node_from_tree): M.
* lib/gl_anytree_list2.h (gl_tree_iterator): MB.
(gl_tree_sortedlist_indexof_from_to): R.
* lib/gl_anytree_omap.h (gl_tree_nx_getput): M.
(gl_tree_iterator): MB.
* lib/gl_anytree_oset.h (gl_tree_nx_add): M.
(gl_tree_update): M.
(gl_tree_iterator): MB.
* lib/gl_anytreehash_list1.h (add_to_bucket): M.
* lib/gl_array_list.c (grow): M.
(gl_array_nx_add_first): M.
(gl_array_nx_add_before): M.
(gl_array_nx_add_after): M.
(gl_array_nx_add_at): M.
(gl_array_remove_node): M.
(gl_array_remove_at): M.
* lib/gl_array_map.c (grow): M.
(gl_array_nx_getput): M.
(gl_array_remove_at): M.
* lib/gl_array_omap.c (grow): M.
(gl_array_nx_add_at): M.
(gl_array_remove_at): M.
* lib/gl_array_oset.c (grow): M.
(gl_array_nx_add_at): M.
(gl_array_remove_at): M.
* lib/gl_array_set.c (grow): M.
* lib/gl_avltree_ordered.h (rebalance): M.
(gl_tree_add_node_before): R.
(gl_tree_add_node_after): R.
(gl_tree_remove_node_no_free): M.
* lib/gl_carray_list.c (gl_carray_node_value): M.
(gl_carray_node_nx_set_value): M.
(gl_carray_get_at): M.
(gl_carray_nx_set_at): M.
(gl_carray_indexof_from_to): M.
(grow): M.
(gl_carray_nx_add_last): M.
(gl_carray_nx_add_at): M.
(gl_carray_remove_at): M.
(gl_carray_iterator_from_to): R.
(gl_carray_sortedlist_indexof_from_to): M.
(gl_carray_sortedlist_nx_add): M.
* lib/gl_rbtree_ordered.h (rebalance_after_add): M.
(gl_tree_remove_node_no_free): M.
* lib/gl_sublist.c (gl_sublist_sortedlist_search_from_to): M.
(gl_sublist_sortedlist_indexof_from_to): M.
* lib/glob.c (__glob): MR.
* lib/globfree.c (globfree): M.
* lib/glthread/lock.c (glthread_rwlock_init_for_glibc): M.
(glthread_rwlock_init_multithreaded): M.
(glthread_rwlock_rdlock_multithreaded): M.
(glthread_rwlock_wrlock_multithreaded): M.
(glthread_rwlock_destroy_multithreaded): M.
(glthread_rwlock_init_multithreaded): M.
(glthread_rwlock_rdlock_multithreaded): M.
(glthread_rwlock_wrlock_multithreaded): M.
(glthread_rwlock_unlock_multithreaded): M.
(glthread_rwlock_destroy_multithreaded): M.
(glthread_recursive_lock_init_multithreaded): M.
(glthread_recursive_lock_lock_multithreaded): M.
(glthread_recursive_lock_destroy_multithreaded): M.
(glthread_recursive_lock_init_multithreaded): M.
(glthread_recursive_lock_lock_multithreaded): M.
* lib/glthread/thread.c (gl_thread_create): M.
* lib/group-member.c (group_member): M.
(main): M.
* lib/hash.c (hash_get_next): MB.
(check_tuning): M.
(hash_initialize): M.
(hash_clear): M.
(hash_free): MS.
(transfer_entries): M.
(hash_rehash): MR.
(hash_insert_if_absent): MR.
(hash_remove): MR.
(hash_print): M.
* lib/hasmntopt.c (hasmntopt): M.
* lib/hmac.c (hmac_hash): R.
(GL_HMAC_FN): R.
* lib/human.c (group_number): MRO.
(human_readable): MR.
(humblock): M.
* lib/hypot.c (hypot): M.
* lib/hypotl.c (hypotl): M.
* lib/i-ring.c (i_ring_pop): M.
* lib/iconv_open.c (rpl_iconv_open): R.
* lib/idcache.c (getuidbyname): M.
(getgidbyname): M.
* lib/inet_ntop.c (inet_ntop4): M.
(inet_ntop6): R.
* lib/inet_pton.c (inet_pton4): MRBO.
(inet_pton6): MRBO.
* lib/ino-map.c (ino_map_insert): M.
* lib/integer_length.c (integer_length): M.
* lib/ioctl.c (rpl_ioctl): M.
(ioctl): M.
* lib/is_l-impl.h (FUNC): M.
* lib/isatty.c (IsCygwinConsoleHandle): R.
* lib/isnan.c (FUNC): MR.
* lib/javacomp.c (compile_using_envjavac): MRB.
(compile_using_javac): MB.
(execute_and_read_line): M.
(write_temp_file): M.
(get_classfile_version): MR.
(is_envjavac_usable): MR.
(is_javac_present): M.
(is_javac_usable): MR.
(compile_java_class): MR.
* lib/javaexec.c (execute_java_class): MRBO.
* lib/javaversion.c (execute_and_read_line): M.
(javaexec_version): R.
* lib/kwset.c (treefails): M.
(kwsprep): MRSB.
(bmexec_trans): MRSO.
(acexec_trans): MRS.
* lib/lchown.c (rpl_lchown): R.
* lib/linebuffer.c (readlinebuffer_delim): RO.
* lib/link.c (link): MRBO.
(rpl_link): M.
* lib/linkat.c (link_immediate): R.
(link_follow): M.
(linkat_follow): M.
* lib/localcharset.c (locale_charset): MR.
* lib/localeinfo.c (is_using_utf8): R. Rename 'mbs' to 'state'.
(init_localeinfo): Rename 's' to 'state'.
* lib/localename.c (gl_locale_name): MSB.
* lib/localename-environ.c (gl_locale_name_environ): MSB.
* lib/localename-unsafe.c (gl_locale_name_canonicalize): MSB.
(gl_locale_name_from_win32_LANGID): M.
(gl_locale_name_from_win32_LCID): M.
(enum_locales_fn): R.
(gl_locale_name_unsafe): MSB.
* lib/log2.c (log2): M.
* lib/log2f.c (log2f): M.
* lib/log2l.c (log2l): M.
* lib/login_tty.c (login_tty): M.
* lib/logl.c (logl): MR.
* lib/long-options.c (parse_long_options): MR.
(parse_gnu_standard_options_only): M.
* lib/mbfile.h (mbfile_multi_getc): MR.
* lib/mbmemcasecoll.c (apply_c32tolower): M.
(mbmemcasecoll): MR.
* lib/mbrtoc32.c (mbrtoc32): R.
* lib/mbrtowc.c (rpl_mbrtowc): MRS.
* lib/mbrtowc-impl.h: MRB.
* lib/mbscasestr.c (knuth_morris_pratt_multibyte): MR.
(mbscasestr): R.
* lib/mbscspn.c (mbscspn): MR.
* lib/mbsnrtowcs-impl.h (FUNC): M.
* lib/mbspbrk.c (mbspbrk): MR.
* lib/mbsrtowcs-impl.h (FUNC): M.
* lib/mbsspn.c (mbsspn): MR.
* lib/mbsstr.c (knuth_morris_pratt_multibyte): MR.
(mbsstr): MR.
* lib/mbswidth.c (mbsnwidth): M.
* lib/mbtowc-impl.h (mbtowc): MR.
* lib/mbtowc-lock.h (mbtowc_with_lock): M.
* lib/mcel.h: MR in comments.
* lib/md2.c (md2_finish_ctx): M.
(md2_process_bytes): M.
(md2_update_chksum): M.
(md2_compress): M.
* lib/md2-stream.c (md2_stream): MR.
* lib/md4.c (md4_finish_ctx): M.
(md4_process_block): MR.
* lib/md4-stream.c (md4_stream): MR.
* lib/md5-stream.c (md5_stream): MR.
* lib/mem-hash-map.c (compute_hashval): M.
(lookup): M.
* lib/memchr.c (__memchr): MRB.
* lib/memchr2.c (memchr2): MRB.
* lib/memrchr.c (__memrchr): MRB.
* lib/mgetgroups.c (mgetgroups): MRS.
* lib/mkancesdirs.c (mkancesdirs): M.
* lib/mkdir.c (rpl_mkdir): MR.
* lib/mkdir-p.c (make_dir_parents): R.
* lib/modechange.c (mode_compile): R.
* lib/mountlist.c (fstype_to_string): M.
(dev_from_mount_options): MR.
(read_file_system_list): MR.
* lib/mpsort.c (mpsort_into_tmp): M.
(mpsort_with_tmp): M.
* lib/msvc-inval.h (TRY_MSVC_INVAL): M.
* lib/mtx.c (mtx_init): MSB.
* lib/nanosleep.c (nanosleep): M.
* lib/nl_langinfo.c (ctype_codeset): MR.
(nl_langinfo_with_lock): M.
* lib/nonblocking.c (get_nonblocking_flag): M.
(set_nonblocking_flag): M.
* lib/nproc.c (num_processors_via_affinity_mask): M.
(cgroup2_mount): MR.
(get_cgroup2_cpu_quota): M.
(parse_omp_threads): Remove variable 'ret'.
(num_processors): M.
* lib/obstack.c (_obstack_newchunk): M.
(_obstack_allocated_p): M.
(__obstack_free): M.
* lib/obstack_printf.c (OBSTACK_PRINTF): M.
(OBSTACK_VPRINTF): M.
* lib/omp-init.c (parse_omp_threads): Remove variable 'ret'.
* lib/openat-proc.c (openat_proc_name): R.
* lib/openat2.c (do_openat2): R.
(openat2): MSB.
* lib/opendir.c (opendir): MR.
* lib/openpty.c (openpty): M.
* lib/os2-spawn.c (prepare_spawn): M.
(spawnpvech): R.
* lib/pagealign_alloc.c (pagealign_alloc): MR.
(pagealign_xalloc): M.
(pagealign_free): M.
* lib/parse-duration.c (parse_scaled_value): M.
(parse_year_month_day): M.
(parse_yearmonthday): MR.
(parse_YMWD): SB.
(parse_hour_minute_second): M.
(parse_hourminutesecond): MR.
(parse_HMS): SB.
(parse_time): M.
(parse_period): MR.
(parse_non_iso8601): M.
* lib/passfd.c (sendfd): MRO.
(recvfd): MRO.
* lib/perror.c (perror): M.
* lib/physmem.c (physmem_total): M.
(physmem_claimable): M.
* lib/pipe-filter-gi.c (filter_loop): MRB.
(pipe_filter_gi_create): M.
(pipe_filter_gi_close): M.
* lib/pipe-filter-ii.c (_beginthreadex): M.
(WaitForMultipleObjects): MR.
(pipe_filter_ii_execute): MRB.
* lib/poll.c (IsSocketHandle): R.
(windows_compute_revents): MRB.
(windows_compute_revents_socket): M.
(poll): MRB. Remove variable 'bRet'.
* lib/popen.c (rpl_popen): MB.
* lib/posix_openpt.c (posix_openpt): M.
* lib/posixtm.c (posix_time_parse): R.
(posixtime): R.
* lib/pread.c (pread): M.
* lib/printf.c (printf): M.
* lib/printf-frexp.c (FUNC): R.
* lib/printf-parse.c (PRINTF_PARSE): MR.
* lib/progreloc.c (maybe_executable): R.
(find_executable): MRSB.
(prepare_relocate): M.
* lib/propername.c (mbsstr_trimmed_wordbounded): RSB.
(proper_name_utf8): M.
* lib/pselect.c (pselect): MR.
* lib/pt_chown.c (do_pt_chown): MR.
* lib/pthread-cond.c (pthread_cond_timedwait): R.
* lib/pthread-rwlock.c (pthread_rwlockattr_init): MSB.
(pthread_rwlock_init): MSB.
(pthread_rwlock_rdlock): MSB.
(pthread_rwlock_wrlock): MSB.
(pthread_rwlock_tryrdlock): MB.
(pthread_rwlock_trywrlock): MB.
(pthread_rwlock_timedrdlock): MSB.
(pthread_rwlock_timedwrlock): MSB.
(pthread_rwlock_unlock): MSB.
(pthread_rwlock_destroy): MSB.
(pthread_rwlock_init): MSB.
(pthread_rwlock_timedrdlock): MRB.
(pthread_rwlock_timedwrlock): MRB.
* lib/pthread_mutex_timedlock.c (pthread_mutex_timedlock): MRB.
* lib/pthread_sigmask.c (pthread_sigmask): MR.
* lib/ptsname_r.c (ptsname_r): MR.
* lib/putenv.c (putenv): M.
* lib/pwrite.c (pwrite): M.
* lib/qcopy-acl.c (qcopy_acl): Remove a use of variable 'ret'.
* lib/qset-acl.c (qset_acl): M.
* lib/qsort.c (_quicksort): MR.
* lib/quotearg.c (set_quoting_flags): M.
(quotearg_buffer_restyled): MRSB.
* lib/random.c (__initstate): M.
(__setstate): M.
(__random): R.
* lib/random_r.c (__srandom_r): M.
(__setstate_r): MO.
(__random_r): M.
* lib/rawmemchr.c (rawmemchr): RB.
* lib/read-file.c (fread_file): M.
(read_file): M.
* lib/readdir.c (readdir): MR.
* lib/readline.c (readline): R.
* lib/readtokens.c (readtoken): R.
(readtokens): M.
* lib/regex-quote.c (regex_quote_spec_gnu): MB.
(regex_quote_spec_pcre): MB.
(regex_quote_length): MR.
(regex_quote): MB.
* lib/relocatable.c (set_this_relocation_prefix): M.
(compute_curr_prefix): MR.
(find_shared_library_fullname): MRS.
(relocate): M.
* lib/relocwrapper.c (activate_libdirs): MB.
(main): M.
* lib/rename.c (rpl_rename): MRBO.
* lib/renameatu.c (renameatu): MRB.
* lib/rijndael-alg-fst.c (rijndaelKeySetupEnc): MSB.
(rijndaelKeySetupDec): MRSB.
(rijndaelEncrypt): MSB.
(rijndaelDecrypt): MSB.
* lib/rijndael-api-fst.c (rijndaelMakeKey): MRSB.
(rijndaelCipherInit): MSB.
(rijndaelBlockEncrypt): MRSB.
(rijndaelPadEncrypt): MRSB.
(rijndaelBlockDecrypt): MRSB.
(rijndaelPadDecrypt): MRSB.
* lib/rmdir.c (rpl_rmdir): M.
* lib/rpmatch.c (localized_pattern): MS.
(try): M.
(rpmatch): MSB.
* lib/same.c (same_nameat): R. Remove variable 'flags'.
* lib/savedir.c (streamsavedir): MRB.
* lib/scandir.c (SCANDIR): MR.
* lib/select.c (IsSocketHandle): R.
(windows_poll_handle): MRSB. Remove variable 'bRet'.
(rpl_select): MR. Remove variable 'bRet'.
* lib/set-permissions.c (set_acls_from_mode): R.
(context_acl_from_mode): R.
(context_aclv_from_mode): M.
(set_acls_from_mode): MR.
(context_acl_from_mode): M.
(set_acls): R.
(set_permissions): MS.
* lib/setenv.c (__add_to_environ): M.
(rpl_setenv): M.
* lib/sethostname.c (sethostname): MR.
* lib/setlocale.c (setlocale_unixlike): MR.
(langcmp): R.
(setlocale_improved): MR.
* lib/setlocale_null.c (setlocale_null_r_with_lock): M.
(setlocale_null): M.
* lib/setsockopt.c (rpl_setsockopt): R.
* lib/sh-quote.c (shell_quote_argv): MB.
* lib/sha1.c (sha1_process_block): R.
* lib/sha1-stream.c (sha1_stream): M.
* lib/sha256.c (sha256_process_block): MR.
* lib/sha256-stream.c (shaxxx_stream): M.
* lib/sha3.c (sha3_read_ctx): R.
(sha3_process_block): R.
* lib/sha3-stream.c (sha3_xxx_stream): M.
* lib/sha512-stream.c (shaxxx_stream): M.
* lib/sig2str.c (str2signum): RS.
(sig2str): MR.
* lib/sigaction.c (sigaction_handler): MR.
(sigaction): MRB.
* lib/sigprocmask.c (sigprocmask): M.
* lib/sigsegv.c (sigsegv_handler): MR.
* lib/sincosl.c (kernel_sinl): MRS.
(kernel_cosl): MRS.
* lib/sinl.c (sinl): MR.
* lib/sleep.c (rpl_sleep): M.
* lib/sm3.c (sm3_process_block): MR.
* lib/sm3-stream.c (sm3_stream): MR.
* lib/snprintf.c (snprintf): M.
* lib/snzprintf.c (snzprintf): M.
* lib/socket.c (rpl_socket): M.
* lib/sockets.c (close_fd_maybe_socket): MR.
(ioctl_fd_maybe_socket): MR.
(gl_sockets_startup): M.
(gl_sockets_cleanup): M.
* lib/spawn-pipe.c (create_pipe): MR.
* lib/spawni.c (__spawni): Split variable declaration.
* lib/sprintf.c (sprintf): M.
* lib/sqrtl.c (sqrtl): MR.
* lib/ssfmalloc.h (allocate_block_from_pool): MSB.
* lib/stackvma.c (rof_open): M.
(vma_iterate_proc): RSB.
(vma_iterate_bsd): MB.
(mapped_range_start): M.
(mapped_range_end): M.
(is_unmapped): MR.
(mapped_range_start): M.
(mapped_range_end): M.
(vma_iterate): MR.
* lib/stat-w32.c (_gl_convert_FILETIME_to_timespec): R.
* lib/stdio-consolesafe.c (gl_consolesafe_fprintf): R.
(gl_consolesafe_printf): R.
* lib/stdio-read.c (CALL_WITH_ERRNO_FIX): M.
(scanf): M.
(fscanf): M.
* lib/stdio-write.c (CALL_WITH_SIGPIPE_EMULATION): M.
(printf): M.
(fprintf): M.
* lib/stpncpy.c (__stpncpy): MSB.
* lib/str-kmp.h (knuth_morris_pratt): M.
* lib/str-two-way.h (critical_factorization): MSB.
(two_way_short_needle): MS.
(two_way_long_needle): MRS.
* lib/strcasecmp.c (strcasecmp): R.
* lib/strcasecmp_l.c (strcasecmp_l): MR.
* lib/strcasestr.c (strcasestr): MRSB.
* lib/strchrnul.c (strchrnul): MRB.
* lib/strerror.c (strerror): M.
* lib/strerror_l.c (strerror_l_r): R.
* lib/strerror_r.c (local_snprintf): M.
(strerror_r): M.
* lib/strfmon_l.c (rpl_strfmon_l): MR.
* lib/strftime.c (__strftime_internal): MR.
* lib/striconv.c (mem_cd_iconv): MR.
(str_cd_iconv): MR.
(str_iconv): M.
* lib/striconveh.c (iconveh_open): MR.
(utf8conv_carefully): M.
(mem_cd_iconveh_internal): MR.
(mem_iconveh): M.
(str_iconveh): M.
* lib/striconveha.c (uniconv_register_autodetect): MRSB.
(mem_iconveha_notranslit): MS.
(mem_iconveha): M.
(str_iconveha_notranslit): MS.
(str_iconveha): M.
* lib/string-buffer-printf.c (sb_appendvf): R.
(sb_appendf): R.
* lib/string-buffer-reversed-printf.c (sbr_prependvf): R.
(sbr_prependf): R.
* lib/string-desc.c (sd_new): R.
* lib/stripslash.c (strip_trailing_slashes): M.
* lib/strncasecmp.c (strncasecmp): R.
* lib/strncasecmp_l.c (strncasecmp_l): MR.
* lib/strptime.c (__strptime_internal): RSB.
* lib/strsep.c (strsep): R.
* lib/strsignal.c (strsignal): R.
* lib/strstr.c (strstr): MRSB.
* lib/strtod.c (parse_number): MR.
(STRTOD): MR.
* lib/strtok_r.c (__strtok_r): M.
* lib/strtol.c (strtol): MR.
* lib/struniq.h (struniq): M.
* lib/supersede.c (open_supersede): R.
* lib/system-quote.c (system_quote_argv): MB.
* lib/szprintf.c (szprintf): M.
* lib/tanl.c (kernel_tanl): MRS.
(tanl): MR.
* lib/tempname.c (try_tempname_len): M.
* lib/term-style-control.c (sprintf_integer): MR.
* lib/textstyle.in.h (ostream_printf): MR.
* lib/time.c (time): M.
* lib/times.c (filetime2clock): M.
* lib/timespec-add.c (timespec_add): R.
* lib/timespec-sub.c (timespec_sub): R.
* lib/tmpdir.c (path_search): MR.
* lib/tmpfile.c (tmpfile): M.
* lib/to_l-impl.h (FUNC): M.
* lib/tparm.c (tparm): MRB.
* lib/trigl.c (ieee754_rem_pio2l): MRS.
(kernel_rem_pio2): MRS.
* lib/trim.c (trim2): MR.
* lib/tsearch.c (check_tree): R.
(maybe_split_for_insert): M.
(__tsearch): MR.
(__tfind): M.
(__tdelete): MRB.
* lib/ttyname_r.c (ttyname_r): M.
* lib/uname.c (uname): MR.
* lib/unicase/locale-language.c (uc_locale_language): M.
* lib/unicase/u-casecmp.h (FUNC): MR.
* lib/unicase/u-casecoll.h (FUNC): MR.
* lib/unicase/u-casemap.h (FUNC): MR.
* lib/unicase/u-casexfrm.h (FUNC): MR.
* lib/unicase/u-ct-casefold.h (FUNC): MR.
* lib/unicase/u-ct-totitle.h (FUNC): MR.
* lib/unicase/u-is-cased.h (FUNC): MR.
* lib/unicase/u-is-invariant.h (FUNC): MR.
* lib/unicase/u8-casefold.c (read_file): M.
* lib/unicase/u8-tolower.c (read_file): M.
* lib/unicase/u8-totitle.c (read_file): M.
* lib/unicase/u8-toupper.c (read_file): M.
* lib/unicase/ulc-casecmp.c (ulc_u8_casefold): MR.
* lib/unicase/ulc-casexfrm.c (ulc_casexfrm): MR.
* lib/unicodeio.c (unicode_to_mb): MR.
* lib/uniconv/u-conv-from-enc.h (FUNC): M.
* lib/uniconv/u-conv-to-enc.h (FUNC): MR.
* lib/uniconv/u-strconv-from-enc.h (FUNC): M.
* lib/uniconv/u-strconv-to-enc.h (FUNC): M.
* lib/uniconv/u16-conv-to-enc.c (FUNC): MR.
* lib/uniconv/u8-conv-from-enc.c (u8_conv_from_encoding): R.
* lib/uniconv/u8-conv-to-enc.c (u8_conv_to_encoding): R.
* lib/uniconv/u8-strconv-to-enc.c (u8_strconv_to_encoding): MS.
* lib/unictype/3level.h (CONCAT(TABLE,_add)): M.
(CONCAT(TABLE,_finalize)): MRB.
* lib/unictype/3levelbit.h (CONCAT(TABLE,_add)): M.
(CONCAT(TABLE,_finalize)): MRB.
* lib/unictype/bidi_byname.c (uc_bidi_class_byname): M.
* lib/unictype/categ_and.c (uc_general_category_and): MR.
* lib/unictype/categ_and_not.c (uc_general_category_and_not): MR.
* lib/unictype/categ_byname.c (uc_general_category_byname): M.
* lib/unictype/categ_of.c (uc_general_category): R.
* lib/unictype/categ_or.c (uc_general_category_or): MR.
* lib/unictype/combiningclass_byname.c (uc_combining_class_byname): M.
* lib/unictype/incb_byname.c (uc_indic_conjunct_break_byname): M.
* lib/unictype/joininggroup_byname.c (uc_joining_group_byname): M.
* lib/unictype/joiningtype_byname.c (uc_joining_type_byname): M.
* lib/unictype/pr_byname.c (uc_property_byname): MRB.
* lib/unictype/scripts.c (uc_script_byname): M.
* lib/unigbrk/u-grapheme-prev.h
(ends_with_incb_consonant_extended_linker_extended): M.
(ends_with_emoji_modifier_sequence): M.
(ends_with_ri_count): M.
(FUNC): M.
* lib/unigbrk/uc-is-grapheme-break.c (uc_is_grapheme_break): M.
* lib/unigbrk/ulc-grapheme-breaks.c (ulc_grapheme_breaks): M.
* lib/unilbrk/u16-width-linebreaks.c (u16_width_linebreaks_internal): M.
* lib/unilbrk/u32-width-linebreaks.c (u32_width_linebreaks_internal): M.
* lib/unilbrk/u8-possible-linebreaks.c (read_file): M.
* lib/unilbrk/u8-width-linebreaks.c (u8_width_linebreaks_internal): M.
(read_file): M.
* lib/unilbrk/ulc-possible-linebreaks.c
(ulc_possible_linebreaks_internal): M.
(read_file): M.
* lib/unilbrk/ulc-width-linebreaks.c (ulc_width_linebreaks_internal): M.
(read_file): M.
* lib/uniname/uniname.c (unicode_name_word): MR.
(unicode_character_name): M.
(unicode_name_character): MR.
* lib/uninorm/canonical-decomposition.c (uc_canonical_decomposition): M.
* lib/uninorm/composition.c (uc_composition): M.
* lib/uninorm/decomposition.c (uc_decomposition): M.
* lib/uninorm/u-normalize-internal.h (FUNC): MR.
* lib/uninorm/u-normcmp.h (FUNC): MR.
* lib/uninorm/u-normcoll.h (FUNC): MR.
* lib/uninorm/u-normxfrm.h (FUNC): MR.
* lib/uninorm/uninorm-filter.c (uninorm_filter_write): M.
* lib/unistdio/u-asnprintf.h (ASNPRINTF): M.
* lib/unistdio/u-asprintf.h (ASPRINTF): M.
* lib/unistdio/u-snprintf.h (SNPRINTF): M.
* lib/unistdio/u-sprintf.h (SPRINTF): M.
* lib/unistdio/u-vsnprintf.h (VSNPRINTF): M.
* lib/unistdio/u-vsprintf.h (VSPRINTF): M.
* lib/unistdio/ulc-fprintf.c (ulc_fprintf): M.
* lib/unistdio/ulc-vfprintf.c (ulc_vfprintf): M.
* lib/unistr/u16-chr.c (u16_chr): R.
* lib/unistr/u16-mbsnlen.c (u16_mbsnlen): M.
* lib/unistr/u16-next.c (u16_next): M.
* lib/unistr/u16-strchr.c (u16_strchr): R.
* lib/unistr/u16-strrchr.c (u16_strrchr): R.
* lib/unistr/u16-to-u32.c (FUNC): MR.
* lib/unistr/u16-to-u8.c (FUNC): MR.
* lib/unistr/u32-next.c (u32_next): M.
* lib/unistr/u32-to-u16.c (FUNC): MR.
* lib/unistr/u32-to-u8.c (FUNC): MR.
* lib/unistr/u8-chr.c (u8_chr): M.
* lib/unistr/u8-mbsnlen.c (u8_mbsnlen): M.
* lib/unistr/u8-next.c (u8_next): M.
* lib/unistr/u8-strchr.c (u8_strchr): R.
* lib/unistr/u8-strrchr.c (u8_strrchr): R.
* lib/unistr/u8-to-u16.c (FUNC): MR.
* lib/unistr/u8-to-u32.c (FUNC): MR.
* lib/uniwbrk/u8-wordbreaks.c (read_file): M.
* lib/uniwbrk/ulc-wordbreaks.c (ulc_wordbreaks): M.
(read_file): M.
* lib/uniwidth/u16-width.c (u16_width): M.
* lib/uniwidth/u32-width.c (u32_width): M.
* lib/uniwidth/u8-width.c (u8_width): M.
* lib/unlinkat.c (rpl_unlinkat): MR.
* lib/unsetenv.c (unsetenv): M.
(rpl_unsetenv): R.
* lib/userspec.c (parse_with_separator): MRS.
(main): MR.
* lib/utime.c (_gl_utimens_windows): M.
* lib/utimecmp.c (utimecmpat): R.
* lib/utimens.c (validate_timespec): R.
(fdutimens): MR.
(lutimens): MR.
* lib/utimensat.c (rpl_utimensat): M.
* lib/vasnprintf.c (divide): M.
(decode_long_double): MR.
(decode_double): MR.
(scale10_round_decimal_decoded): MR.
(floorlog10l): MR.
(floorlog10): MR.
(VASNPRINTF): MR.
* lib/vc-mtime.c (is_git_present): MR.
(git_vc_controlled): MR.
(git_unmodified): M.
(git_mtime): MR.
(abs_git_checkout): MR.
(max_vc_mtime): MR.
* lib/vdzprintf.c (vdzprintf): M.
* lib/vfzprintf.c (vfzprintf): M.
* lib/vma-iter.c (rof_open): M.
(vma_iterate_proc): MRSB.
(vma_iterate_bsd): MB.
(vma_iterate): MR.
* lib/vsnzprintf.c (vsnzprintf): M.
* lib/vszprintf.c (vszprintf): M.
* lib/wait-process.c (klibc_waitpid): M.
(wait_subprocess): MR.
* lib/wcs-two-way.h (critical_factorization): MSB.
(two_way_short_needle): MS.
* lib/wcsstr-impl.h (FUNC): MRSB.
* lib/wcswidth-impl.h (FUNC): B.
* lib/wcsxfrm-impl.h (wcsxfrm): MR.
* lib/wctomb-impl.h (wctomb): M.
* lib/wgetcwd-lgpl.c (wgetcwd): MRS.
* lib/windows-cond.c (glwthread_waitqueue_add): M.
(glwthread_waitqueue_notify_first): M.
(glwthread_waitqueue_notify_all): M.
(glwthread_cond_wait): M.
(glwthread_cond_timedwait): MRS.
* lib/windows-cygpath.c (execute_and_read_line): MR.
* lib/windows-rwlock.c (glwthread_waitqueue_add): M.
(glwthread_rwlock_rdlock): M.
(glwthread_rwlock_wrlock): M.
* lib/windows-spawn.c (quoted_arg_length): M.
(quoted_arg_string): M.
(prepare_spawn): MR.
(compose_command): MRB.
(compose_envblock): RSB.
* lib/windows-thread.c (glwthread_thread_self): M.
(glwthread_thread_create): M.
* lib/windows-timedmutex.c (glwthread_timedmutex_timedlock): MR.
* lib/windows-timedrecmutex.c (glwthread_timedrecmutex_timedlock): MR.
* lib/windows-timedrwlock.c (glwthread_waitqueue_add): M.
(glwthread_waitqueue_notify_first): M.
(glwthread_waitqueue_notify_all): M.
(glwthread_timedrwlock_rdlock): M.
(glwthread_timedrwlock_wrlock): M.
(glwthread_timedrwlock_timedrdlock): MR.
(glwthread_timedrwlock_timedwrlock): MR.
* lib/xasprintf.c (xasprintf): M.
* lib/xconcat-filename.c (xconcatenated_filename): M.
* lib/xmalloc.c (xpalloc): R.
* lib/xmalloca.c (xmmalloca): M.
* lib/xprintf.c (xprintf): M.
(xfprintf): M.
* lib/xstring-buffer-printf.c (sb_xappendf): M.
* lib/xstring-buffer-reversed-printf.c (sbr_xprependf): M.
* lib/xstrtod.c (XSTRTOD): MR.
* lib/xstrtol.c (__xstrtol): R.
* lib/xstrtol-error.c (xstrtol_error): R.
* lib/xvasprintf.c (xstrcat): MB.
(xvasprintf): R.
* lib/zprintf.c (zprintf): M.
This commit is contained in:
Bruno Haible
2025-12-10 00:23:48 +01:00
parent fe01cb91c5
commit 6edf6dbacf
514 changed files with 9036 additions and 9881 deletions
+988
View File
@@ -1,3 +1,991 @@
2025-12-09 Bruno Haible <bruno@clisp.org>
lib: Reduce scope of local variables.
M = Move variable declaration to its initialization.
R = Reduce scope.
S = Split scope, create separate variables from one variable.
B = Insert braces, creating a block scope.
O = Change order of initializations.
* lib/accept4.c (accept4): M.
* lib/acl-internal.c (acl_ace_nontrivial): R.
* lib/acosl.c (acosl): MS.
* lib/af_alg.c (afalg_stream): B.
* lib/alignalloc.h (alignalloc): R.
* lib/alloca.c (find_stack_direction): M.
(alloca): M.
* lib/amemxfrm.c (amemxfrm): MR.
* lib/arcfour.c (arcfour_stream): MB.
(arcfour_setkey): MB.
* lib/arctwo.c (arctwo_encrypt): M.
(arctwo_decrypt): M.
(arctwo_setkey_ekb): M.
* lib/areadlink-with-size.c (areadlink_with_size): MR.
* lib/areadlinkat-with-size.c (areadlinkat_with_size): MR.
* lib/argmatch.c (argmatch): MO.
(main): RBO.
* lib/argp-fmtstream.c (__argp_make_fmtstream): M.
(__argp_fmtstream_update): M.
(__argp_fmtstream_ensure): R.
(__argp_fmtstream_printf): R.
* lib/argp-fmtstream.h (__argp_fmtstream_set_lmargin): M.
(__argp_fmtstream_set_rmargin): M.
(__argp_fmtstream_set_wmargin): M.
* lib/argp-help.c (validate_uparams): M.
(fill_in_uparams): MR.
(make_hol): MRSO.
(hol_entry_short_iterate): R.
(hol_entry_long_iterate): R.
(hol_entry_first_long): Rename 'num' to 'nopts'.
(canon_doc_option): M.
(hol_append): MR.
(argp_hol): O.
(hol_entry_help): RSBO.
(hol_help): RB.
(usage_argful_short_opt): R.
(usage_long_opt): R.
(hol_usage): SB.
(argp_args_levels): R.
(argp_args_usage): MRB.
(argp_doc): RBO.
(_help): MR.
(__argp_error): R.
* lib/argp-parse.c (group_parse): M.
(parser_init): MRB.
(parser_finalize): MS.
(parser_parse_next): R.
(__argp_parse): MR.
(__argp_input): M.
* lib/argz.c (argz_add_sep): M.
(argz_create_sep): M.
(argz_create): R.
(argz_replace): RB.
* lib/asinl.c (asinl): MRS.
* lib/asnprintf.c (asnprintf): M.
* lib/asnwprintf.c (asnwprintf): M.
* lib/asprintf.c (asprintf): M.
* lib/astrxfrm.c (astrxfrm): MR.
* lib/aszprintf.c (aszprintf): M.
* lib/at-func.c (AT_FUNC_NAME): MR.
* lib/at-func2.c (at_func2): MRS.
* lib/atanl.c (atanl): MRS.
* lib/backupfile.c (numbered_backup): R.
* lib/base32.c (decode_8): R.
(base32_decode_ctx): R.
* lib/base64.c (decode_4): R.
(base64_decode_ctx): R.
* lib/basename-lgpl.c (last_component): R.
(base_len): RO.
* lib/bitset.c (bitset_copy_): R.
* lib/bitset/list.c (lbitset_prune): MR.
(lbitset_weed): MR.
(lbitset_list): SB.
* lib/bitset/table.c (tbitset_list): SB.
* lib/boot-time-aux.h (get_windows_boot_time_fallback): R.
* lib/btoc32.c (btoc32): R.
* lib/c-asprintf.c (c_asprintf): M.
* lib/c-aszprintf.c (c_aszprintf): M.
* lib/c-snprintf.c (c_snprintf): M.
* lib/c-snzprintf.c (c_snzprintf): M.
* lib/c-strcasecmp.c (c_strcasecmp): R.
* lib/c-strcasestr.c (c_strcasestr): MRSB.
* lib/c-strncasecmp.c (c_strncasecmp): R.
* lib/c-strtod.c (C_STRTOD): R.
* lib/c-vsnzprintf.c (c_vsnzprintf): M.
* lib/c-xasprintf.c (c_xasprintf): M.
* lib/c32tob.c (c32tob): R.
* lib/canon-host.c (canon_host_r): MR.
* lib/canonicalize.c (canonicalize_filename_mode_stk): R.
* lib/canonicalize-lgpl.c (realpath_stk): R.
* lib/cbrt.c (cbrt): M.
* lib/cbrtf.c (cbrtf): M.
* lib/cbrtl.c (cbrtl): MR.
* lib/chdir-long.c (chdir_long): M.
(main): MR.
* lib/classpath.c (new_classpath): MB.
* lib/clean-temp.c (create_temp_dir): M.
(unregister_temp_file): M.
(unregister_temp_subdir): M.
(cleanup_temp_file): M.
(cleanup_temp_subdir): M.
(cleanup_temp_dir_contents): MSB.
(open_temp): R.
(fopen_temp): R.
(close_temp): RB.
(fclose_variant_temp): RB.
* lib/clean-temp-simple.c (cleanup_action): MSB.
(cleanup_temporary_file): M.
* lib/copy-file.c (copy_file_internal): MRB.
* lib/cosl.c (cosl): MR.
* lib/crc-generate-table.c (make_crc_table): M.
* lib/crc-x86_64-pclmul.c (crc32_update_no_xor_pclmul): MRSB.
* lib/crc.c (crc32_update_no_xor_slice_by_8): S.
(crc32_update_no_xor_slice_by_n): M.
(crc32_update_no_xor): MR.
* lib/csharpcomp.c (compile_csharp_using_mono): MRB.
(compile_csharp_using_dotnet): MRSB.
(compile_csharp_using_sscli): MRB.
* lib/csharpexec.c (execute_csharp_using_mono): MO.
(execute_csharp_using_dotnet): MO.
(execute_csharp_using_sscli): MO.
(execute_csharp_program): R.
* lib/cygpath.c (execute_and_read_line): M.
* lib/des.c (gl_des_is_weak_key): M.
(gl_3des_ecb_crypt): MO.
* lib/dfa.c (closure): B.
(dfamust): MRB.
* lib/di-set.c (map_device): M.
(di_set_insert): M.
(di_set_lookup): M.
* lib/dirname-lgpl.c (dir_len): R.
* lib/dprintf.c (dprintf): M.
* lib/dup.c (dup_nothrow): R.
* lib/dup2.c (ms_windows_dup2): M.
(klibc_dup2dirfd): M.
(klibc_dup2): MR.
(rpl_dup2): M.
* lib/dup3.c (dup3): M.
* lib/duplocale.c (duplocale): MRSB.
* lib/dzprintf.c (dzprintf): M.
* lib/euidaccess.c (euidaccess): MR.
(main): M.
* lib/exclude.c (add_exclude): R.
* lib/execl.c (execl): SB.
* lib/execle.c (execle): SB.
* lib/execlp.c (execlp): SB.
* lib/execute.c (execute): R.
* lib/fchdir.c (ensure_dirs_slot): M.
(get_name): M.
(_gl_register_fd): R.
* lib/fclose.c (rpl_fclose): MR.
* lib/fcntl.c (dupfd): RO.
(fcntl): R.
(klibc_dupdirfd): M.
(klibc_fcntl): MRSB.
* lib/fdopen.c (rpl_fdopen): M.
* lib/file-has-acl.c (get_aclinfo): R.
(fdfile_has_aclinfo): MR.
* lib/file-remote.c (main): M.
* lib/file-set.c (record_file): M.
(seen_file): R.
* lib/findprog.c (find_in_path): MR.
* lib/findprog-in.c (find_in_given_path): MR.
* lib/flock.c (do_lock): MR.
(do_unlock): M.
(flock): MR.
* lib/fma.c (decode): M.
* lib/fopen.c (rpl_fopen): MR.
* lib/forkpty.c (forkpty): M.
* lib/fprintf.c (fprintf): M.
* lib/freadseek.c (freadseek): MR.
* lib/freopen.c (rpl_freopen): M.
* lib/freopen-safer.c (freopen_safer): M.
* lib/frexp.c (FUNC): MR.
* lib/fseterr.c (fseterr): M.
* lib/fstatat.c (rpl_fstatat): M.
* lib/fstrcmp.c (fstrcmp_free_resources): M.
(fstrcmp_bounded): MR.
* lib/fsusage.c (statvfs_works): R.
* lib/fsync.c (fsync): M.
* lib/ftello.c (ftello): M.
* lib/ftruncate.c (SetFileSize): M.
* lib/fts.c (fts_open): MR.
(fts_load): M.
(fts_close): MR.
(filesystem_type): MRO.
(fts_read): MB.
(fts_children): M.
(fts_build): MR.
(fts_cross_check): RO.
(fd_ring_print): RO.
(fts_stat): RO.
(fts_sort): R.
(fts_alloc): M.
(fts_lfree): R.
(fts_palloc): M.
(fts_padjust): MS.
(fts_maxarglen): M.
(fts_safe_changedir): MR.
* lib/fts-cycle.c (enter_dir): MRO.
(leave_dir): M.
* lib/fzprintf.c (fzprintf): M.
* lib/gc-gnulib.c (gc_cipher_open): MR.
(gc_cipher_setkey): MSB.
(gc_cipher_setiv): M.
(gc_cipher_encrypt_inline): M.
(gc_cipher_decrypt_inline): M.
(gc_hash_open): MR.
(gc_hash_clone): M.
* lib/gc-libgcrypt.c (gc_init): Remove local variable 'err'.
(gc_cipher_open): MR.
(gc_cipher_setkey): M.
(gc_cipher_setiv): M.
(gc_hash_open): MR.
(gc_hash_clone): M.
(gc_md4): MR.
(gc_md5): MR.
(gc_sha1): MR.
(gc_sha256): MR.
(gc_sha512): MR.
(gc_sm3): MR.
(gc_hmac_md5): MR. Remove local variable 'err'.
(gc_hmac_sha1): MR. Remove local variable 'err'.
(gc_hmac_sha256): MR. Remove local variable 'err'.
(gc_hmac_sha512): MR. Remove local variable 'err'.
* lib/gc-pbkdf2.c (gc_pbkdf2_prf): MR.
* lib/gen-uni-tables.c (fill_attributes): M.
(debug_output_predicate): M.
(output_predicate_test): M.
(output_predicate): MR.
(output_category): MR.
(output_combclass): MR.
(output_bidi_category): MR.
(output_decimal_digit_test): M.
(output_decimal_digit): MR.
(output_digit_test): M.
(output_digit): MR.
(output_numeric_test): M.
(output_numeric): MR.
(fill_mirror): MR.
(get_mirror_value): M.
(output_mirror): MR.
(fill_properties): MR.
(fill_property30): MR.
(output_indic_conjunct_break_test): M.
(output_indic_conjunct_break): MR.
(fill_arabicshaping): MR.
(output_joining_type_test): M.
(output_joining_type): MR.
(output_joining_group_test): M.
(output_joining_group): MR.
(fill_scripts): MR.
(output_scripts): MR.
(output_scripts_byname): M.
(fill_blocks): MR.
(output_blocks): M.
(output_ident_category): MR.
(output_charclass): MR.
(output_charmap): MR.
(output_tables): M.
(fill_width): MR.
(output_nonspacing_property): MR.
(output_width_property_test): M.
(debug_output_lbrk_tables): M.
(fill_org_lbp): MR.
(debug_output_org_lbrk_tables): M.
(output_lbpea): M.
(output_lbrk_tables): R.
(output_lbrk_rules_as_tables): M.
(debug_output_wbrk_tables): M.
(fill_org_wbp): MR.
(debug_output_org_wbrk_tables): M.
(output_wbp): M.
(output_wbrk_tables): M.
(output_gbp_test): MR.
(output_gbp_table): MR.
(fill_org_gbp): MR.
(get_decomposition): MR.
(output_decomposition): M.
(output_decomposition_tables): R.
(fill_composition_exclusions): MR.
(debug_output_composition_tables): M.
(output_composition_tables): MSB.
(output_simple_mapping_test): M.
(output_simple_mapping): MR.
(fill_casing_rules): MR.
(fill_casefolding_rules): MR.
(output_casing_rules): M.
(output_version): MR.
* lib/get-rusage-as.c (get_rusage_as_via_setrlimit): R.
(get_rusage_as): M.
* lib/get-rusage-data.c (get_rusage_data_via_setrlimit): R.
(get_rusage_data): M.
* lib/get_ppid_of.c (get_ppid_of): M.
* lib/get_progname_of.c (get_progname_of): MR.
* lib/getaddrinfo.c (use_win32_p): M.
(getaddrinfo): MR.
(freeaddrinfo): M.
* lib/getcwd.c (__getcwd_generic): MRSBO.
* lib/getcwd-lgpl.c (rpl_getcwd): MS.
* lib/getdelim.c (getdelim): MR.
* lib/getdomainname.c (getdomainname): M.
* lib/getentropy.c (getentropy): R.
* lib/getgroups.c (rpl_getgroups): MR.
* lib/gethostname.c (rpl_gethostname): M.
* lib/getloadavg.c (getloadavg): MRB.
* lib/getlocalename_l-unsafe.c (newlocale): MR.
(duplocale): MR.
(freelocale): M.
* lib/getlogin_r.c (getlogin_r): M.
* lib/getndelim2.c (getndelim2): MR.
* lib/getopt.c (exchange): MS.
(process_long_option): MRB.
(_getopt_internal_r): MR.
(_getopt_internal): M.
(main): M.
* lib/getopt1.c (main): M.
* lib/getpass.c (getpass): MRB.
* lib/getprogname.c (getprogname): M.
* lib/getrusage.c (getrusage): M.
* lib/getsockopt.c (rpl_getsockopt): M.
* lib/getsubopt.c (getsubopt): M.
* lib/gettext.h (dcpgettext_expr): M.
(dcnpgettext_expr): M.
* lib/gettimeofday.c (gettimeofday): R.
* lib/getugroups.c (getugroups): MR.
* lib/getumask.c (getumask): R.
* lib/gl_anyavltree_list2.h (rebalance): MR.
(gl_tree_remove_node_from_tree): MR.
(gl_tree_nx_add_before): R.
(gl_tree_nx_add_after): R.
* lib/gl_anyhash2.h (hash_resize): M.
* lib/gl_anylinked_list2.h (gl_linked_get_at): R.
(gl_linked_nx_set_at): R.
(gl_linked_search_from_to): R.
(gl_linked_indexof_from_to): MR.
(gl_linked_nx_add_at): M.
(gl_linked_remove_node): M.
(gl_linked_remove_at): MR.
(gl_linked_iterator_from_to): M.
(gl_linked_sortedlist_search_from_to): R.
(gl_linked_sortedlist_indexof_from_to): R.
* lib/gl_anyrbtree_list2.h (rebalance_after_add): MR.
(gl_tree_remove_node_from_tree): M.
* lib/gl_anytree_list2.h (gl_tree_iterator): MB.
(gl_tree_sortedlist_indexof_from_to): R.
* lib/gl_anytree_omap.h (gl_tree_nx_getput): M.
(gl_tree_iterator): MB.
* lib/gl_anytree_oset.h (gl_tree_nx_add): M.
(gl_tree_update): M.
(gl_tree_iterator): MB.
* lib/gl_anytreehash_list1.h (add_to_bucket): M.
* lib/gl_array_list.c (grow): M.
(gl_array_nx_add_first): M.
(gl_array_nx_add_before): M.
(gl_array_nx_add_after): M.
(gl_array_nx_add_at): M.
(gl_array_remove_node): M.
(gl_array_remove_at): M.
* lib/gl_array_map.c (grow): M.
(gl_array_nx_getput): M.
(gl_array_remove_at): M.
* lib/gl_array_omap.c (grow): M.
(gl_array_nx_add_at): M.
(gl_array_remove_at): M.
* lib/gl_array_oset.c (grow): M.
(gl_array_nx_add_at): M.
(gl_array_remove_at): M.
* lib/gl_array_set.c (grow): M.
* lib/gl_avltree_ordered.h (rebalance): M.
(gl_tree_add_node_before): R.
(gl_tree_add_node_after): R.
(gl_tree_remove_node_no_free): M.
* lib/gl_carray_list.c (gl_carray_node_value): M.
(gl_carray_node_nx_set_value): M.
(gl_carray_get_at): M.
(gl_carray_nx_set_at): M.
(gl_carray_indexof_from_to): M.
(grow): M.
(gl_carray_nx_add_last): M.
(gl_carray_nx_add_at): M.
(gl_carray_remove_at): M.
(gl_carray_iterator_from_to): R.
(gl_carray_sortedlist_indexof_from_to): M.
(gl_carray_sortedlist_nx_add): M.
* lib/gl_rbtree_ordered.h (rebalance_after_add): M.
(gl_tree_remove_node_no_free): M.
* lib/gl_sublist.c (gl_sublist_sortedlist_search_from_to): M.
(gl_sublist_sortedlist_indexof_from_to): M.
* lib/glob.c (__glob): MR.
* lib/globfree.c (globfree): M.
* lib/glthread/lock.c (glthread_rwlock_init_for_glibc): M.
(glthread_rwlock_init_multithreaded): M.
(glthread_rwlock_rdlock_multithreaded): M.
(glthread_rwlock_wrlock_multithreaded): M.
(glthread_rwlock_destroy_multithreaded): M.
(glthread_rwlock_init_multithreaded): M.
(glthread_rwlock_rdlock_multithreaded): M.
(glthread_rwlock_wrlock_multithreaded): M.
(glthread_rwlock_unlock_multithreaded): M.
(glthread_rwlock_destroy_multithreaded): M.
(glthread_recursive_lock_init_multithreaded): M.
(glthread_recursive_lock_lock_multithreaded): M.
(glthread_recursive_lock_destroy_multithreaded): M.
(glthread_recursive_lock_init_multithreaded): M.
(glthread_recursive_lock_lock_multithreaded): M.
* lib/glthread/thread.c (gl_thread_create): M.
* lib/group-member.c (group_member): M.
(main): M.
* lib/hash.c (hash_get_next): MB.
(check_tuning): M.
(hash_initialize): M.
(hash_clear): M.
(hash_free): MS.
(transfer_entries): M.
(hash_rehash): MR.
(hash_insert_if_absent): MR.
(hash_remove): MR.
(hash_print): M.
* lib/hasmntopt.c (hasmntopt): M.
* lib/hmac.c (hmac_hash): R.
(GL_HMAC_FN): R.
* lib/human.c (group_number): MRO.
(human_readable): MR.
(humblock): M.
* lib/hypot.c (hypot): M.
* lib/hypotl.c (hypotl): M.
* lib/i-ring.c (i_ring_pop): M.
* lib/iconv_open.c (rpl_iconv_open): R.
* lib/idcache.c (getuidbyname): M.
(getgidbyname): M.
* lib/inet_ntop.c (inet_ntop4): M.
(inet_ntop6): R.
* lib/inet_pton.c (inet_pton4): MRBO.
(inet_pton6): MRBO.
* lib/ino-map.c (ino_map_insert): M.
* lib/integer_length.c (integer_length): M.
* lib/ioctl.c (rpl_ioctl): M.
(ioctl): M.
* lib/is_l-impl.h (FUNC): M.
* lib/isatty.c (IsCygwinConsoleHandle): R.
* lib/isnan.c (FUNC): MR.
* lib/javacomp.c (compile_using_envjavac): MRB.
(compile_using_javac): MB.
(execute_and_read_line): M.
(write_temp_file): M.
(get_classfile_version): MR.
(is_envjavac_usable): MR.
(is_javac_present): M.
(is_javac_usable): MR.
(compile_java_class): MR.
* lib/javaexec.c (execute_java_class): MRBO.
* lib/javaversion.c (execute_and_read_line): M.
(javaexec_version): R.
* lib/kwset.c (treefails): M.
(kwsprep): MRSB.
(bmexec_trans): MRSO.
(acexec_trans): MRS.
* lib/lchown.c (rpl_lchown): R.
* lib/linebuffer.c (readlinebuffer_delim): RO.
* lib/link.c (link): MRBO.
(rpl_link): M.
* lib/linkat.c (link_immediate): R.
(link_follow): M.
(linkat_follow): M.
* lib/localcharset.c (locale_charset): MR.
* lib/localeinfo.c (is_using_utf8): R. Rename 'mbs' to 'state'.
(init_localeinfo): Rename 's' to 'state'.
* lib/localename.c (gl_locale_name): MSB.
* lib/localename-environ.c (gl_locale_name_environ): MSB.
* lib/localename-unsafe.c (gl_locale_name_canonicalize): MSB.
(gl_locale_name_from_win32_LANGID): M.
(gl_locale_name_from_win32_LCID): M.
(enum_locales_fn): R.
(gl_locale_name_unsafe): MSB.
* lib/log2.c (log2): M.
* lib/log2f.c (log2f): M.
* lib/log2l.c (log2l): M.
* lib/login_tty.c (login_tty): M.
* lib/logl.c (logl): MR.
* lib/long-options.c (parse_long_options): MR.
(parse_gnu_standard_options_only): M.
* lib/mbfile.h (mbfile_multi_getc): MR.
* lib/mbmemcasecoll.c (apply_c32tolower): M.
(mbmemcasecoll): MR.
* lib/mbrtoc32.c (mbrtoc32): R.
* lib/mbrtowc.c (rpl_mbrtowc): MRS.
* lib/mbrtowc-impl.h: MRB.
* lib/mbscasestr.c (knuth_morris_pratt_multibyte): MR.
(mbscasestr): R.
* lib/mbscspn.c (mbscspn): MR.
* lib/mbsnrtowcs-impl.h (FUNC): M.
* lib/mbspbrk.c (mbspbrk): MR.
* lib/mbsrtowcs-impl.h (FUNC): M.
* lib/mbsspn.c (mbsspn): MR.
* lib/mbsstr.c (knuth_morris_pratt_multibyte): MR.
(mbsstr): MR.
* lib/mbswidth.c (mbsnwidth): M.
* lib/mbtowc-impl.h (mbtowc): MR.
* lib/mbtowc-lock.h (mbtowc_with_lock): M.
* lib/mcel.h: MR in comments.
* lib/md2.c (md2_finish_ctx): M.
(md2_process_bytes): M.
(md2_update_chksum): M.
(md2_compress): M.
* lib/md2-stream.c (md2_stream): MR.
* lib/md4.c (md4_finish_ctx): M.
(md4_process_block): MR.
* lib/md4-stream.c (md4_stream): MR.
* lib/md5-stream.c (md5_stream): MR.
* lib/mem-hash-map.c (compute_hashval): M.
(lookup): M.
* lib/memchr.c (__memchr): MRB.
* lib/memchr2.c (memchr2): MRB.
* lib/memrchr.c (__memrchr): MRB.
* lib/mgetgroups.c (mgetgroups): MRS.
* lib/mkancesdirs.c (mkancesdirs): M.
* lib/mkdir.c (rpl_mkdir): MR.
* lib/mkdir-p.c (make_dir_parents): R.
* lib/modechange.c (mode_compile): R.
* lib/mountlist.c (fstype_to_string): M.
(dev_from_mount_options): MR.
(read_file_system_list): MR.
* lib/mpsort.c (mpsort_into_tmp): M.
(mpsort_with_tmp): M.
* lib/msvc-inval.h (TRY_MSVC_INVAL): M.
* lib/mtx.c (mtx_init): MSB.
* lib/nanosleep.c (nanosleep): M.
* lib/nl_langinfo.c (ctype_codeset): MR.
(nl_langinfo_with_lock): M.
* lib/nonblocking.c (get_nonblocking_flag): M.
(set_nonblocking_flag): M.
* lib/nproc.c (num_processors_via_affinity_mask): M.
(cgroup2_mount): MR.
(get_cgroup2_cpu_quota): M.
(parse_omp_threads): Remove variable 'ret'.
(num_processors): M.
* lib/obstack.c (_obstack_newchunk): M.
(_obstack_allocated_p): M.
(__obstack_free): M.
* lib/obstack_printf.c (OBSTACK_PRINTF): M.
(OBSTACK_VPRINTF): M.
* lib/omp-init.c (parse_omp_threads): Remove variable 'ret'.
* lib/openat-proc.c (openat_proc_name): R.
* lib/openat2.c (do_openat2): R.
(openat2): MSB.
* lib/opendir.c (opendir): MR.
* lib/openpty.c (openpty): M.
* lib/os2-spawn.c (prepare_spawn): M.
(spawnpvech): R.
* lib/pagealign_alloc.c (pagealign_alloc): MR.
(pagealign_xalloc): M.
(pagealign_free): M.
* lib/parse-duration.c (parse_scaled_value): M.
(parse_year_month_day): M.
(parse_yearmonthday): MR.
(parse_YMWD): SB.
(parse_hour_minute_second): M.
(parse_hourminutesecond): MR.
(parse_HMS): SB.
(parse_time): M.
(parse_period): MR.
(parse_non_iso8601): M.
* lib/passfd.c (sendfd): MRO.
(recvfd): MRO.
* lib/perror.c (perror): M.
* lib/physmem.c (physmem_total): M.
(physmem_claimable): M.
* lib/pipe-filter-gi.c (filter_loop): MRB.
(pipe_filter_gi_create): M.
(pipe_filter_gi_close): M.
* lib/pipe-filter-ii.c (_beginthreadex): M.
(WaitForMultipleObjects): MR.
(pipe_filter_ii_execute): MRB.
* lib/poll.c (IsSocketHandle): R.
(windows_compute_revents): MRB.
(windows_compute_revents_socket): M.
(poll): MRB. Remove variable 'bRet'.
* lib/popen.c (rpl_popen): MB.
* lib/posix_openpt.c (posix_openpt): M.
* lib/posixtm.c (posix_time_parse): R.
(posixtime): R.
* lib/pread.c (pread): M.
* lib/printf.c (printf): M.
* lib/printf-frexp.c (FUNC): R.
* lib/printf-parse.c (PRINTF_PARSE): MR.
* lib/progreloc.c (maybe_executable): R.
(find_executable): MRSB.
(prepare_relocate): M.
* lib/propername.c (mbsstr_trimmed_wordbounded): RSB.
(proper_name_utf8): M.
* lib/pselect.c (pselect): MR.
* lib/pt_chown.c (do_pt_chown): MR.
* lib/pthread-cond.c (pthread_cond_timedwait): R.
* lib/pthread-rwlock.c (pthread_rwlockattr_init): MSB.
(pthread_rwlock_init): MSB.
(pthread_rwlock_rdlock): MSB.
(pthread_rwlock_wrlock): MSB.
(pthread_rwlock_tryrdlock): MB.
(pthread_rwlock_trywrlock): MB.
(pthread_rwlock_timedrdlock): MSB.
(pthread_rwlock_timedwrlock): MSB.
(pthread_rwlock_unlock): MSB.
(pthread_rwlock_destroy): MSB.
(pthread_rwlock_init): MSB.
(pthread_rwlock_timedrdlock): MRB.
(pthread_rwlock_timedwrlock): MRB.
* lib/pthread_mutex_timedlock.c (pthread_mutex_timedlock): MRB.
* lib/pthread_sigmask.c (pthread_sigmask): MR.
* lib/ptsname_r.c (ptsname_r): MR.
* lib/putenv.c (putenv): M.
* lib/pwrite.c (pwrite): M.
* lib/qcopy-acl.c (qcopy_acl): Remove a use of variable 'ret'.
* lib/qset-acl.c (qset_acl): M.
* lib/qsort.c (_quicksort): MR.
* lib/quotearg.c (set_quoting_flags): M.
(quotearg_buffer_restyled): MRSB.
* lib/random.c (__initstate): M.
(__setstate): M.
(__random): R.
* lib/random_r.c (__srandom_r): M.
(__setstate_r): MO.
(__random_r): M.
* lib/rawmemchr.c (rawmemchr): RB.
* lib/read-file.c (fread_file): M.
(read_file): M.
* lib/readdir.c (readdir): MR.
* lib/readline.c (readline): R.
* lib/readtokens.c (readtoken): R.
(readtokens): M.
* lib/regex-quote.c (regex_quote_spec_gnu): MB.
(regex_quote_spec_pcre): MB.
(regex_quote_length): MR.
(regex_quote): MB.
* lib/relocatable.c (set_this_relocation_prefix): M.
(compute_curr_prefix): MR.
(find_shared_library_fullname): MRS.
(relocate): M.
* lib/relocwrapper.c (activate_libdirs): MB.
(main): M.
* lib/rename.c (rpl_rename): MRBO.
* lib/renameatu.c (renameatu): MRB.
* lib/rijndael-alg-fst.c (rijndaelKeySetupEnc): MSB.
(rijndaelKeySetupDec): MRSB.
(rijndaelEncrypt): MSB.
(rijndaelDecrypt): MSB.
* lib/rijndael-api-fst.c (rijndaelMakeKey): MRSB.
(rijndaelCipherInit): MSB.
(rijndaelBlockEncrypt): MRSB.
(rijndaelPadEncrypt): MRSB.
(rijndaelBlockDecrypt): MRSB.
(rijndaelPadDecrypt): MRSB.
* lib/rmdir.c (rpl_rmdir): M.
* lib/rpmatch.c (localized_pattern): MS.
(try): M.
(rpmatch): MSB.
* lib/same.c (same_nameat): R. Remove variable 'flags'.
* lib/savedir.c (streamsavedir): MRB.
* lib/scandir.c (SCANDIR): MR.
* lib/select.c (IsSocketHandle): R.
(windows_poll_handle): MRSB. Remove variable 'bRet'.
(rpl_select): MR. Remove variable 'bRet'.
* lib/set-permissions.c (set_acls_from_mode): R.
(context_acl_from_mode): R.
(context_aclv_from_mode): M.
(set_acls_from_mode): MR.
(context_acl_from_mode): M.
(set_acls): R.
(set_permissions): MS.
* lib/setenv.c (__add_to_environ): M.
(rpl_setenv): M.
* lib/sethostname.c (sethostname): MR.
* lib/setlocale.c (setlocale_unixlike): MR.
(langcmp): R.
(setlocale_improved): MR.
* lib/setlocale_null.c (setlocale_null_r_with_lock): M.
(setlocale_null): M.
* lib/setsockopt.c (rpl_setsockopt): R.
* lib/sh-quote.c (shell_quote_argv): MB.
* lib/sha1.c (sha1_process_block): R.
* lib/sha1-stream.c (sha1_stream): M.
* lib/sha256.c (sha256_process_block): MR.
* lib/sha256-stream.c (shaxxx_stream): M.
* lib/sha3.c (sha3_read_ctx): R.
(sha3_process_block): R.
* lib/sha3-stream.c (sha3_xxx_stream): M.
* lib/sha512-stream.c (shaxxx_stream): M.
* lib/sig2str.c (str2signum): RS.
(sig2str): MR.
* lib/sigaction.c (sigaction_handler): MR.
(sigaction): MRB.
* lib/sigprocmask.c (sigprocmask): M.
* lib/sigsegv.c (sigsegv_handler): MR.
* lib/sincosl.c (kernel_sinl): MRS.
(kernel_cosl): MRS.
* lib/sinl.c (sinl): MR.
* lib/sleep.c (rpl_sleep): M.
* lib/sm3.c (sm3_process_block): MR.
* lib/sm3-stream.c (sm3_stream): MR.
* lib/snprintf.c (snprintf): M.
* lib/snzprintf.c (snzprintf): M.
* lib/socket.c (rpl_socket): M.
* lib/sockets.c (close_fd_maybe_socket): MR.
(ioctl_fd_maybe_socket): MR.
(gl_sockets_startup): M.
(gl_sockets_cleanup): M.
* lib/spawn-pipe.c (create_pipe): MR.
* lib/spawni.c (__spawni): Split variable declaration.
* lib/sprintf.c (sprintf): M.
* lib/sqrtl.c (sqrtl): MR.
* lib/ssfmalloc.h (allocate_block_from_pool): MSB.
* lib/stackvma.c (rof_open): M.
(vma_iterate_proc): RSB.
(vma_iterate_bsd): MB.
(mapped_range_start): M.
(mapped_range_end): M.
(is_unmapped): MR.
(mapped_range_start): M.
(mapped_range_end): M.
(vma_iterate): MR.
* lib/stat-w32.c (_gl_convert_FILETIME_to_timespec): R.
* lib/stdio-consolesafe.c (gl_consolesafe_fprintf): R.
(gl_consolesafe_printf): R.
* lib/stdio-read.c (CALL_WITH_ERRNO_FIX): M.
(scanf): M.
(fscanf): M.
* lib/stdio-write.c (CALL_WITH_SIGPIPE_EMULATION): M.
(printf): M.
(fprintf): M.
* lib/stpncpy.c (__stpncpy): MSB.
* lib/str-kmp.h (knuth_morris_pratt): M.
* lib/str-two-way.h (critical_factorization): MSB.
(two_way_short_needle): MS.
(two_way_long_needle): MRS.
* lib/strcasecmp.c (strcasecmp): R.
* lib/strcasecmp_l.c (strcasecmp_l): MR.
* lib/strcasestr.c (strcasestr): MRSB.
* lib/strchrnul.c (strchrnul): MRB.
* lib/strerror.c (strerror): M.
* lib/strerror_l.c (strerror_l_r): R.
* lib/strerror_r.c (local_snprintf): M.
(strerror_r): M.
* lib/strfmon_l.c (rpl_strfmon_l): MR.
* lib/strftime.c (__strftime_internal): MR.
* lib/striconv.c (mem_cd_iconv): MR.
(str_cd_iconv): MR.
(str_iconv): M.
* lib/striconveh.c (iconveh_open): MR.
(utf8conv_carefully): M.
(mem_cd_iconveh_internal): MR.
(mem_iconveh): M.
(str_iconveh): M.
* lib/striconveha.c (uniconv_register_autodetect): MRSB.
(mem_iconveha_notranslit): MS.
(mem_iconveha): M.
(str_iconveha_notranslit): MS.
(str_iconveha): M.
* lib/string-buffer-printf.c (sb_appendvf): R.
(sb_appendf): R.
* lib/string-buffer-reversed-printf.c (sbr_prependvf): R.
(sbr_prependf): R.
* lib/string-desc.c (sd_new): R.
* lib/stripslash.c (strip_trailing_slashes): M.
* lib/strncasecmp.c (strncasecmp): R.
* lib/strncasecmp_l.c (strncasecmp_l): MR.
* lib/strptime.c (__strptime_internal): RSB.
* lib/strsep.c (strsep): R.
* lib/strsignal.c (strsignal): R.
* lib/strstr.c (strstr): MRSB.
* lib/strtod.c (parse_number): MR.
(STRTOD): MR.
* lib/strtok_r.c (__strtok_r): M.
* lib/strtol.c (strtol): MR.
* lib/struniq.h (struniq): M.
* lib/supersede.c (open_supersede): R.
* lib/system-quote.c (system_quote_argv): MB.
* lib/szprintf.c (szprintf): M.
* lib/tanl.c (kernel_tanl): MRS.
(tanl): MR.
* lib/tempname.c (try_tempname_len): M.
* lib/term-style-control.c (sprintf_integer): MR.
* lib/textstyle.in.h (ostream_printf): MR.
* lib/time.c (time): M.
* lib/times.c (filetime2clock): M.
* lib/timespec-add.c (timespec_add): R.
* lib/timespec-sub.c (timespec_sub): R.
* lib/tmpdir.c (path_search): MR.
* lib/tmpfile.c (tmpfile): M.
* lib/to_l-impl.h (FUNC): M.
* lib/tparm.c (tparm): MRB.
* lib/trigl.c (ieee754_rem_pio2l): MRS.
(kernel_rem_pio2): MRS.
* lib/trim.c (trim2): MR.
* lib/tsearch.c (check_tree): R.
(maybe_split_for_insert): M.
(__tsearch): MR.
(__tfind): M.
(__tdelete): MRB.
* lib/ttyname_r.c (ttyname_r): M.
* lib/uname.c (uname): MR.
* lib/unicase/locale-language.c (uc_locale_language): M.
* lib/unicase/u-casecmp.h (FUNC): MR.
* lib/unicase/u-casecoll.h (FUNC): MR.
* lib/unicase/u-casemap.h (FUNC): MR.
* lib/unicase/u-casexfrm.h (FUNC): MR.
* lib/unicase/u-ct-casefold.h (FUNC): MR.
* lib/unicase/u-ct-totitle.h (FUNC): MR.
* lib/unicase/u-is-cased.h (FUNC): MR.
* lib/unicase/u-is-invariant.h (FUNC): MR.
* lib/unicase/u8-casefold.c (read_file): M.
* lib/unicase/u8-tolower.c (read_file): M.
* lib/unicase/u8-totitle.c (read_file): M.
* lib/unicase/u8-toupper.c (read_file): M.
* lib/unicase/ulc-casecmp.c (ulc_u8_casefold): MR.
* lib/unicase/ulc-casexfrm.c (ulc_casexfrm): MR.
* lib/unicodeio.c (unicode_to_mb): MR.
* lib/uniconv/u-conv-from-enc.h (FUNC): M.
* lib/uniconv/u-conv-to-enc.h (FUNC): MR.
* lib/uniconv/u-strconv-from-enc.h (FUNC): M.
* lib/uniconv/u-strconv-to-enc.h (FUNC): M.
* lib/uniconv/u16-conv-to-enc.c (FUNC): MR.
* lib/uniconv/u8-conv-from-enc.c (u8_conv_from_encoding): R.
* lib/uniconv/u8-conv-to-enc.c (u8_conv_to_encoding): R.
* lib/uniconv/u8-strconv-to-enc.c (u8_strconv_to_encoding): MS.
* lib/unictype/3level.h (CONCAT(TABLE,_add)): M.
(CONCAT(TABLE,_finalize)): MRB.
* lib/unictype/3levelbit.h (CONCAT(TABLE,_add)): M.
(CONCAT(TABLE,_finalize)): MRB.
* lib/unictype/bidi_byname.c (uc_bidi_class_byname): M.
* lib/unictype/categ_and.c (uc_general_category_and): MR.
* lib/unictype/categ_and_not.c (uc_general_category_and_not): MR.
* lib/unictype/categ_byname.c (uc_general_category_byname): M.
* lib/unictype/categ_of.c (uc_general_category): R.
* lib/unictype/categ_or.c (uc_general_category_or): MR.
* lib/unictype/combiningclass_byname.c (uc_combining_class_byname): M.
* lib/unictype/incb_byname.c (uc_indic_conjunct_break_byname): M.
* lib/unictype/joininggroup_byname.c (uc_joining_group_byname): M.
* lib/unictype/joiningtype_byname.c (uc_joining_type_byname): M.
* lib/unictype/pr_byname.c (uc_property_byname): MRB.
* lib/unictype/scripts.c (uc_script_byname): M.
* lib/unigbrk/u-grapheme-prev.h
(ends_with_incb_consonant_extended_linker_extended): M.
(ends_with_emoji_modifier_sequence): M.
(ends_with_ri_count): M.
(FUNC): M.
* lib/unigbrk/uc-is-grapheme-break.c (uc_is_grapheme_break): M.
* lib/unigbrk/ulc-grapheme-breaks.c (ulc_grapheme_breaks): M.
* lib/unilbrk/u16-width-linebreaks.c (u16_width_linebreaks_internal): M.
* lib/unilbrk/u32-width-linebreaks.c (u32_width_linebreaks_internal): M.
* lib/unilbrk/u8-possible-linebreaks.c (read_file): M.
* lib/unilbrk/u8-width-linebreaks.c (u8_width_linebreaks_internal): M.
(read_file): M.
* lib/unilbrk/ulc-possible-linebreaks.c
(ulc_possible_linebreaks_internal): M.
(read_file): M.
* lib/unilbrk/ulc-width-linebreaks.c (ulc_width_linebreaks_internal): M.
(read_file): M.
* lib/uniname/uniname.c (unicode_name_word): MR.
(unicode_character_name): M.
(unicode_name_character): MR.
* lib/uninorm/canonical-decomposition.c (uc_canonical_decomposition): M.
* lib/uninorm/composition.c (uc_composition): M.
* lib/uninorm/decomposition.c (uc_decomposition): M.
* lib/uninorm/u-normalize-internal.h (FUNC): MR.
* lib/uninorm/u-normcmp.h (FUNC): MR.
* lib/uninorm/u-normcoll.h (FUNC): MR.
* lib/uninorm/u-normxfrm.h (FUNC): MR.
* lib/uninorm/uninorm-filter.c (uninorm_filter_write): M.
* lib/unistdio/u-asnprintf.h (ASNPRINTF): M.
* lib/unistdio/u-asprintf.h (ASPRINTF): M.
* lib/unistdio/u-snprintf.h (SNPRINTF): M.
* lib/unistdio/u-sprintf.h (SPRINTF): M.
* lib/unistdio/u-vsnprintf.h (VSNPRINTF): M.
* lib/unistdio/u-vsprintf.h (VSPRINTF): M.
* lib/unistdio/ulc-fprintf.c (ulc_fprintf): M.
* lib/unistdio/ulc-vfprintf.c (ulc_vfprintf): M.
* lib/unistr/u16-chr.c (u16_chr): R.
* lib/unistr/u16-mbsnlen.c (u16_mbsnlen): M.
* lib/unistr/u16-next.c (u16_next): M.
* lib/unistr/u16-strchr.c (u16_strchr): R.
* lib/unistr/u16-strrchr.c (u16_strrchr): R.
* lib/unistr/u16-to-u32.c (FUNC): MR.
* lib/unistr/u16-to-u8.c (FUNC): MR.
* lib/unistr/u32-next.c (u32_next): M.
* lib/unistr/u32-to-u16.c (FUNC): MR.
* lib/unistr/u32-to-u8.c (FUNC): MR.
* lib/unistr/u8-chr.c (u8_chr): M.
* lib/unistr/u8-mbsnlen.c (u8_mbsnlen): M.
* lib/unistr/u8-next.c (u8_next): M.
* lib/unistr/u8-strchr.c (u8_strchr): R.
* lib/unistr/u8-strrchr.c (u8_strrchr): R.
* lib/unistr/u8-to-u16.c (FUNC): MR.
* lib/unistr/u8-to-u32.c (FUNC): MR.
* lib/uniwbrk/u8-wordbreaks.c (read_file): M.
* lib/uniwbrk/ulc-wordbreaks.c (ulc_wordbreaks): M.
(read_file): M.
* lib/uniwidth/u16-width.c (u16_width): M.
* lib/uniwidth/u32-width.c (u32_width): M.
* lib/uniwidth/u8-width.c (u8_width): M.
* lib/unlinkat.c (rpl_unlinkat): MR.
* lib/unsetenv.c (unsetenv): M.
(rpl_unsetenv): R.
* lib/userspec.c (parse_with_separator): MRS.
(main): MR.
* lib/utime.c (_gl_utimens_windows): M.
* lib/utimecmp.c (utimecmpat): R.
* lib/utimens.c (validate_timespec): R.
(fdutimens): MR.
(lutimens): MR.
* lib/utimensat.c (rpl_utimensat): M.
* lib/vasnprintf.c (divide): M.
(decode_long_double): MR.
(decode_double): MR.
(scale10_round_decimal_decoded): MR.
(floorlog10l): MR.
(floorlog10): MR.
(VASNPRINTF): MR.
* lib/vc-mtime.c (is_git_present): MR.
(git_vc_controlled): MR.
(git_unmodified): M.
(git_mtime): MR.
(abs_git_checkout): MR.
(max_vc_mtime): MR.
* lib/vdzprintf.c (vdzprintf): M.
* lib/vfzprintf.c (vfzprintf): M.
* lib/vma-iter.c (rof_open): M.
(vma_iterate_proc): MRSB.
(vma_iterate_bsd): MB.
(vma_iterate): MR.
* lib/vsnzprintf.c (vsnzprintf): M.
* lib/vszprintf.c (vszprintf): M.
* lib/wait-process.c (klibc_waitpid): M.
(wait_subprocess): MR.
* lib/wcs-two-way.h (critical_factorization): MSB.
(two_way_short_needle): MS.
* lib/wcsstr-impl.h (FUNC): MRSB.
* lib/wcswidth-impl.h (FUNC): B.
* lib/wcsxfrm-impl.h (wcsxfrm): MR.
* lib/wctomb-impl.h (wctomb): M.
* lib/wgetcwd-lgpl.c (wgetcwd): MRS.
* lib/windows-cond.c (glwthread_waitqueue_add): M.
(glwthread_waitqueue_notify_first): M.
(glwthread_waitqueue_notify_all): M.
(glwthread_cond_wait): M.
(glwthread_cond_timedwait): MRS.
* lib/windows-cygpath.c (execute_and_read_line): MR.
* lib/windows-rwlock.c (glwthread_waitqueue_add): M.
(glwthread_rwlock_rdlock): M.
(glwthread_rwlock_wrlock): M.
* lib/windows-spawn.c (quoted_arg_length): M.
(quoted_arg_string): M.
(prepare_spawn): MR.
(compose_command): MRB.
(compose_envblock): RSB.
* lib/windows-thread.c (glwthread_thread_self): M.
(glwthread_thread_create): M.
* lib/windows-timedmutex.c (glwthread_timedmutex_timedlock): MR.
* lib/windows-timedrecmutex.c (glwthread_timedrecmutex_timedlock): MR.
* lib/windows-timedrwlock.c (glwthread_waitqueue_add): M.
(glwthread_waitqueue_notify_first): M.
(glwthread_waitqueue_notify_all): M.
(glwthread_timedrwlock_rdlock): M.
(glwthread_timedrwlock_wrlock): M.
(glwthread_timedrwlock_timedrdlock): MR.
(glwthread_timedrwlock_timedwrlock): MR.
* lib/xasprintf.c (xasprintf): M.
* lib/xconcat-filename.c (xconcatenated_filename): M.
* lib/xmalloc.c (xpalloc): R.
* lib/xmalloca.c (xmmalloca): M.
* lib/xprintf.c (xprintf): M.
(xfprintf): M.
* lib/xstring-buffer-printf.c (sb_xappendf): M.
* lib/xstring-buffer-reversed-printf.c (sbr_xprependf): M.
* lib/xstrtod.c (XSTRTOD): MR.
* lib/xstrtol.c (__xstrtol): R.
* lib/xstrtol-error.c (xstrtol_error): R.
* lib/xvasprintf.c (xstrcat): MB.
(xvasprintf): R.
* lib/zprintf.c (zprintf): M.
2025-12-09 Bruno Haible <bruno@clisp.org>
Remove unnecessary variable initializations.
+4 -7
View File
@@ -38,8 +38,6 @@
int
accept4 (int sockfd, struct sockaddr *addr, socklen_t *addrlen, int flags)
{
int fd;
#if HAVE_DECL_ACCEPT4
# undef accept4
/* Try the system call first, if it exists. (We may be running with a glibc
@@ -67,7 +65,7 @@ accept4 (int sockfd, struct sockaddr *addr, socklen_t *addrlen, int flags)
return -1;
}
fd = accept (sockfd, addr, addrlen);
int fd = accept (sockfd, addr, addrlen);
if (fd < 0)
return -1;
@@ -78,9 +76,8 @@ accept4 (int sockfd, struct sockaddr *addr, socklen_t *addrlen, int flags)
{
HANDLE curr_process = GetCurrentProcess ();
HANDLE old_handle = (HANDLE) _get_osfhandle (fd);
HANDLE new_handle;
int nfd;
HANDLE new_handle;
if (!DuplicateHandle (curr_process, /* SourceProcessHandle */
old_handle, /* SourceHandle */
curr_process, /* TargetProcessHandle */
@@ -97,8 +94,8 @@ accept4 (int sockfd, struct sockaddr *addr, socklen_t *addrlen, int flags)
/* Closing fd before allocating the new fd ensures that the new fd will
have the minimum possible value. */
close (fd);
nfd = _open_osfhandle ((intptr_t) new_handle,
O_NOINHERIT | (flags & (O_TEXT | O_BINARY)));
int nfd = _open_osfhandle ((intptr_t) new_handle,
O_NOINHERIT | (flags & (O_TEXT | O_BINARY)));
if (nfd < 0)
{
CloseHandle (new_handle);
+2 -2
View File
@@ -237,9 +237,8 @@ acl_ace_nontrivial (int count, ace_t *entries)
for (int i = 0; i < count; i++)
{
ace_t *ace = &entries[i];
unsigned int index1;
unsigned int index2;
unsigned int index1;
if (ace->a_type == NEW_ACE_ACCESS_ALLOWED_ACE_TYPE)
index1 = 1;
else if (ace->a_type == NEW_ACE_ACCESS_DENIED_ACE_TYPE)
@@ -247,6 +246,7 @@ acl_ace_nontrivial (int count, ace_t *entries)
else
return 1;
unsigned int index2;
if (ace->a_flags == NEW_ACE_OWNER)
index2 = 0;
else if (ace->a_flags == (NEW_ACE_GROUP | NEW_ACE_IDENTIFIER_GROUP))
+44 -44
View File
@@ -134,7 +134,7 @@ static const long double
long double
acosl (long double x)
{
long double t, p, q;
long double t;
if (x < 0.0L)
{
@@ -151,34 +151,34 @@ acosl (long double x)
return (x - x) / (x - x); /* asin(|x|>1) is NaN */
}
else if (x < 0.5L) /* |x| < 0.5 */
if (x < 0.5L) /* |x| < 0.5 */
{
if (x < 0.000000000000000006938893903907228377647697925567626953125L) /* |x| < 2**-57 */
/* acos(0)=+-pi/2 with inexact */
return x * pio2_hi + x * pio2_lo;
t = x * x;
p = (((((((((pS9 * t
+ pS8) * t
+ pS7) * t
+ pS6) * t
+ pS5) * t
+ pS4) * t
+ pS3) * t
+ pS2) * t
+ pS1) * t
+ pS0) * t;
long double p = (((((((((pS9 * t
+ pS8) * t
+ pS7) * t
+ pS6) * t
+ pS5) * t
+ pS4) * t
+ pS3) * t
+ pS2) * t
+ pS1) * t
+ pS0) * t;
q = (((((((( t
+ qS8) * t
+ qS7) * t
+ qS6) * t
+ qS5) * t
+ qS4) * t
+ qS3) * t
+ qS2) * t
+ qS1) * t
+ qS0;
long double q = (((((((( t
+ qS8) * t
+ qS7) * t
+ qS6) * t
+ qS5) * t
+ qS4) * t
+ qS3) * t
+ qS2) * t
+ qS1) * t
+ qS0;
return pio2_hi - (x + x * (p / q) - pio2_lo);
}
@@ -186,29 +186,29 @@ acosl (long double x)
else if (x < 0.625) /* 0.625 */
{
t = x - 0.5625;
p = ((((((((((rS10 * t
+ rS9) * t
+ rS8) * t
+ rS7) * t
+ rS6) * t
+ rS5) * t
+ rS4) * t
+ rS3) * t
+ rS2) * t
+ rS1) * t
+ rS0) * t;
long double p = ((((((((((rS10 * t
+ rS9) * t
+ rS8) * t
+ rS7) * t
+ rS6) * t
+ rS5) * t
+ rS4) * t
+ rS3) * t
+ rS2) * t
+ rS1) * t
+ rS0) * t;
q = ((((((((( t
+ sS9) * t
+ sS8) * t
+ sS7) * t
+ sS6) * t
+ sS5) * t
+ sS4) * t
+ sS3) * t
+ sS2) * t
+ sS1) * t
+ sS0;
long double q = ((((((((( t
+ sS9) * t
+ sS8) * t
+ sS7) * t
+ sS6) * t
+ sS5) * t
+ sS4) * t
+ sS3) * t
+ sS2) * t
+ sS1) * t
+ sS0;
return (pio2_hi - asinr5625) - (p / q - pio2_lo);
}
+93 -91
View File
@@ -112,100 +112,102 @@ afalg_stream (FILE *stream, const char *alg,
read-write loop work around an empty-input bug noted below. */
int fd = fileno (stream);
int result;
struct stat st;
off_t off = ftello (stream);
if (0 <= off && fstat (fd, &st) == 0
&& (S_ISREG (st.st_mode) || S_TYPEISSHM (&st) || S_TYPEISTMO (&st))
&& off < st.st_size && st.st_size - off < SYS_BUFSIZE_MAX)
{
/* Make sure the offset of fileno (stream) reflects how many bytes
have been read from stream before this function got invoked.
Note: fflush on an input stream after ungetc does not work as expected
on some platforms. Therefore this situation is not supported here. */
if (fflush (stream))
result = -EIO;
else
{
off_t nbytes = st.st_size - off;
if (sendfile (ofd, fd, &off, nbytes) == nbytes)
{
if (read (ofd, resblock, hashlen) == hashlen)
{
/* The input buffers of stream are no longer valid. */
if (lseek (fd, off, SEEK_SET) != (off_t)-1)
result = 0;
else
/* The file position of fd has not changed. */
result = -EAFNOSUPPORT;
}
else
/* The file position of fd has not changed. */
result = -EAFNOSUPPORT;
}
else
/* The file position of fd has not changed. */
result = -EAFNOSUPPORT;
}
}
else
{
/* sendfile not possible, do a classic read-write loop. */
/* Number of bytes to seek (backwards) in case of error. */
off_t nseek = 0;
for (;;)
{
char buf[BLOCKSIZE];
/* When the stream is not seekable, start with a single-byte block,
so that we can use ungetc() in the case that send() fails. */
size_t blocksize = (nseek == 0 && off < 0 ? 1 : BLOCKSIZE);
ssize_t size = fread (buf, 1, blocksize, stream);
if (size == 0)
{
/* On Linux < 4.9, the value for an empty stream is wrong (all 0).
See <https://patchwork.kernel.org/patch/9308641/>.
This was not fixed properly until November 2016,
see <https://patchwork.kernel.org/patch/9434741/>. */
result = ferror (stream) ? -EIO : nseek == 0 ? -EAFNOSUPPORT : 0;
break;
}
nseek -= size;
if (send (ofd, buf, size, MSG_MORE) != size)
{
if (nseek == -1)
{
/* 1 byte of pushback buffer is guaranteed on stream, even
if stream is not seekable. */
ungetc ((unsigned char) buf[0], stream);
{
struct stat st;
off_t off = ftello (stream);
if (0 <= off && fstat (fd, &st) == 0
&& (S_ISREG (st.st_mode) || S_TYPEISSHM (&st) || S_TYPEISTMO (&st))
&& off < st.st_size && st.st_size - off < SYS_BUFSIZE_MAX)
{
/* Make sure the offset of fileno (stream) reflects how many bytes
have been read from stream before this function got invoked.
Note: fflush on an input stream after ungetc does not work as expected
on some platforms. Therefore this situation is not supported here. */
if (fflush (stream))
result = -EIO;
else
{
off_t nbytes = st.st_size - off;
if (sendfile (ofd, fd, &off, nbytes) == nbytes)
{
if (read (ofd, resblock, hashlen) == hashlen)
{
/* The input buffers of stream are no longer valid. */
if (lseek (fd, off, SEEK_SET) != (off_t)-1)
result = 0;
else
/* The file position of fd has not changed. */
result = -EAFNOSUPPORT;
}
else
/* The file position of fd has not changed. */
result = -EAFNOSUPPORT;
}
else if (fseeko (stream, nseek, SEEK_CUR) == 0)
/* The position of stream has been restored. */
result = -EAFNOSUPPORT;
else
result = -EIO;
break;
}
}
else
/* The file position of fd has not changed. */
result = -EAFNOSUPPORT;
}
}
else
{
/* sendfile not possible, do a classic read-write loop. */
/* Don't assume that EOF is sticky. See:
<https://sourceware.org/PR19476>. */
if (feof (stream))
{
result = 0;
break;
}
}
/* Number of bytes to seek (backwards) in case of error. */
off_t nseek = 0;
if (result == 0 && read (ofd, resblock, hashlen) != hashlen)
{
if (nseek == 0 || fseeko (stream, nseek, SEEK_CUR) == 0)
/* The position of stream has been restored. */
result = -EAFNOSUPPORT;
else
result = -EIO;
}
}
for (;;)
{
char buf[BLOCKSIZE];
/* When the stream is not seekable, start with a single-byte block,
so that we can use ungetc() in the case that send() fails. */
size_t blocksize = (nseek == 0 && off < 0 ? 1 : BLOCKSIZE);
ssize_t size = fread (buf, 1, blocksize, stream);
if (size == 0)
{
/* On Linux < 4.9, the value for an empty stream is wrong (all 0).
See <https://patchwork.kernel.org/patch/9308641/>.
This was not fixed properly until November 2016,
see <https://patchwork.kernel.org/patch/9434741/>. */
result = ferror (stream) ? -EIO : nseek == 0 ? -EAFNOSUPPORT : 0;
break;
}
nseek -= size;
if (send (ofd, buf, size, MSG_MORE) != size)
{
if (nseek == -1)
{
/* 1 byte of pushback buffer is guaranteed on stream, even
if stream is not seekable. */
ungetc ((unsigned char) buf[0], stream);
result = -EAFNOSUPPORT;
}
else if (fseeko (stream, nseek, SEEK_CUR) == 0)
/* The position of stream has been restored. */
result = -EAFNOSUPPORT;
else
result = -EIO;
break;
}
/* Don't assume that EOF is sticky. See:
<https://sourceware.org/PR19476>. */
if (feof (stream))
{
result = 0;
break;
}
}
if (result == 0 && read (ofd, resblock, hashlen) != hashlen)
{
if (nseek == 0 || fseeko (stream, nseek, SEEK_CUR) == 0)
/* The position of stream has been restored. */
result = -EAFNOSUPPORT;
else
result = -EIO;
}
}
}
close (ofd);
return result;
}
+1 -1
View File
@@ -97,9 +97,9 @@ alignalloc (idx_t alignment, idx_t size)
# if ALIGNALLOC_VIA_ALIGNED_ALLOC
return aligned_alloc (alignment, size);
# else
void *ptr = NULL;
if (alignment < sizeof (void *))
alignment = sizeof (void *);
void *ptr = NULL;
/* Work around posix_memalign glitch by treating a 0 size as if it were 1,
so that returning NULL is equivalent to failing. */
errno = posix_memalign (&ptr, alignment, size ? size : 1);
+3 -6
View File
@@ -61,11 +61,11 @@ static int stack_dir; /* 1 or -1 once known. */
static int
find_stack_direction (int *addr, int depth)
{
int dir, dummy = 0;
int dummy = 0;
if (! addr)
addr = &dummy;
*addr = addr < &dummy ? 1 : addr == &dummy ? 0 : -1;
dir = depth ? find_stack_direction (addr, depth - 1) : 0;
int dir = depth ? find_stack_direction (addr, depth - 1) : 0;
return dir + dummy;
}
@@ -140,14 +140,11 @@ alloca (size_t size)
/* Allocate combined header + user data storage. */
{
/* Address of header. */
register header *new;
size_t combined_size = sizeof (header) + size;
if (combined_size < sizeof (header))
memory_full ();
new = malloc (combined_size);
register header *new = malloc (combined_size);
if (! new)
memory_full ();
+10 -20
View File
@@ -29,12 +29,7 @@ amemxfrm (char *s, size_t n, char *resultbuf, size_t *lengthp)
{
/* Result accumulator. */
char *result;
size_t length;
size_t allocated;
char orig_sentinel;
/* Initial memory allocation. */
if (resultbuf != NULL && *lengthp > 0)
{
result = resultbuf;
@@ -47,10 +42,10 @@ amemxfrm (char *s, size_t n, char *resultbuf, size_t *lengthp)
if (result == NULL)
goto out_of_memory_2;
}
length = 0;
size_t length = 0;
/* Add sentinel.byte. */
orig_sentinel = s[n];
char orig_sentinel = s[n];
s[n] = '\0';
/* Iterate through S, transforming each NUL terminated segment.
@@ -60,16 +55,13 @@ amemxfrm (char *s, size_t n, char *resultbuf, size_t *lengthp)
const char *p_end = s + n + 1;
const char *p;
p = s;
for (;;)
for (p = s;;)
{
/* Search next NUL byte. */
size_t l = strlen (p);
for (;;)
{
size_t k;
/* A call to strxfrm costs about 20 times more than a call to
strdup of the result. Therefore it is worth to try to avoid
calling strxfrm more than once on a given string, by making
@@ -79,14 +71,13 @@ amemxfrm (char *s, size_t n, char *resultbuf, size_t *lengthp)
if (3 * l >= allocated - length)
{
/* Grow the result buffer. */
size_t new_allocated;
char *new_result;
new_allocated = length + 3 * l + 1;
size_t new_allocated = length + 3 * l + 1;
if (new_allocated < 2 * allocated)
new_allocated = 2 * allocated;
if (new_allocated < 64)
new_allocated = 64;
char *new_result;
if (result == resultbuf)
new_result = (char *) malloc (new_allocated);
else
@@ -99,20 +90,19 @@ amemxfrm (char *s, size_t n, char *resultbuf, size_t *lengthp)
}
errno = 0;
k = strxfrm (result + length, p, allocated - length);
size_t k = strxfrm (result + length, p, allocated - length);
if (errno != 0)
goto fail;
if (k >= allocated - length)
{
/* Grow the result buffer. */
size_t new_allocated;
char *new_result;
new_allocated = length + k + 1;
size_t new_allocated = length + k + 1;
if (new_allocated < 2 * allocated)
new_allocated = 2 * allocated;
if (new_allocated < 64)
new_allocated = 64;
char *new_result;
if (result == resultbuf)
new_result = (char *) malloc (new_allocated);
else
+10 -9
View File
@@ -38,13 +38,13 @@ arcfour_stream (arcfour_context * context, const char *inbuf, char *outbuf,
for (; length > 0; length--)
{
char t;
i++;
j += sbox[i];
t = sbox[i];
sbox[i] = sbox[j];
sbox[j] = t;
{
char t = sbox[i];
sbox[i] = sbox[j];
sbox[j] = t;
}
*outbuf++ = (*inbuf++
^ sbox[(0U + sbox[i] + sbox[j]) % ARCFOUR_SBOX_SIZE]);
}
@@ -65,11 +65,12 @@ arcfour_setkey (arcfour_context * context, const char *key, size_t keylen)
size_t i, j, k;
for (i = j = k = 0; i < ARCFOUR_SBOX_SIZE; i++)
{
char t;
j = (j + sbox[i] + key[k]) % ARCFOUR_SBOX_SIZE;
t = sbox[i];
sbox[i] = sbox[j];
sbox[j] = t;
{
char t = sbox[i];
sbox[i] = sbox[j];
sbox[j] = t;
}
if (++k == keylen)
k = 0;
}
+6 -10
View File
@@ -80,7 +80,6 @@ arctwo_encrypt (arctwo_context *context, const char *inbuf,
for (; length >= ARCTWO_BLOCK_SIZE; length -= ARCTWO_BLOCK_SIZE,
inbuf += ARCTWO_BLOCK_SIZE, outbuf += ARCTWO_BLOCK_SIZE)
{
size_t j;
uint16_t word0 = 0, word1 = 0, word2 = 0, word3 = 0;
word0 = (word0 << 8) | to_uchar (inbuf[1]);
@@ -94,7 +93,7 @@ arctwo_encrypt (arctwo_context *context, const char *inbuf,
for (size_t i = 0; i < 16; i++)
{
j = i * 4;
size_t j = i * 4;
/* For some reason I cannot combine those steps. */
word0 += (word1 & ~word3) + (word2 & word3) + context->S[j];
word0 = rotl16 (word0, 1);
@@ -135,7 +134,6 @@ arctwo_decrypt (arctwo_context *context, const char *inbuf,
for (; length >= ARCTWO_BLOCK_SIZE; length -= ARCTWO_BLOCK_SIZE,
inbuf += ARCTWO_BLOCK_SIZE, outbuf += ARCTWO_BLOCK_SIZE)
{
size_t j;
uint16_t word0 = 0, word1 = 0, word2 = 0, word3 = 0;
word0 = (word0 << 8) | to_uchar (inbuf[1]);
@@ -149,7 +147,7 @@ arctwo_decrypt (arctwo_context *context, const char *inbuf,
for (size_t i = 16; i > 0; i--)
{
j = (i - 1) * 4;
size_t j = (i - 1) * 4;
word3 = rotr16 (word3, 5);
word3 -= (word0 & ~word2) + (word1 & word2) + context->S[j + 3];
@@ -167,8 +165,8 @@ arctwo_decrypt (arctwo_context *context, const char *inbuf,
{
word3 = word3 - context->S[word2 & 63];
word2 = word2 - context->S[word1 & 63];
word1 = word1 - context->S[word0 & 63];
word0 = word0 - context->S[word3 & 63];
word1 = word1 - context->S[word0 & 63];
word0 = word0 - context->S[word3 & 63];
}
}
@@ -187,12 +185,10 @@ void
arctwo_setkey_ekb (arctwo_context *context,
size_t keylen, const char *key, size_t effective_keylen)
{
uint8_t *S, x;
if (keylen < 40 / 8 || effective_keylen > 1024)
return;
S = (uint8_t *) context->S;
uint8_t *S = (uint8_t *) context->S;
for (size_t i = 0; i < keylen; i++)
S[i] = (uint8_t) key[i];
@@ -209,7 +205,7 @@ arctwo_setkey_ekb (arctwo_context *context,
{
size_t len = (effective_keylen + 7) >> 3;
size_t i = 128 - len;
x = arctwo_sbox[S[i] & (255 >> (7 & -effective_keylen))];
uint8_t x = arctwo_sbox[S[i] & (255 >> (7 & -effective_keylen))];
S[i] = x;
while (i--)
+2 -5
View File
@@ -65,8 +65,6 @@ areadlink_with_size (char const *file, size_t size)
while (1)
{
ssize_t r;
size_t link_length;
char stackbuf[stackbuf_size];
char *buf = stackbuf;
char *buffer = NULL;
@@ -81,15 +79,14 @@ areadlink_with_size (char const *file, size_t size)
}
}
r = readlink (file, buf, buf_size);
link_length = r;
ssize_t r = readlink (file, buf, buf_size);
if (r < 0)
{
free (buffer);
return NULL;
}
size_t link_length = r;
if (link_length < buf_size)
{
buf[link_length] = 0;
+2 -5
View File
@@ -70,8 +70,6 @@ areadlinkat_with_size (int fd, char const *file, size_t size)
while (1)
{
ssize_t r;
size_t link_length;
char stackbuf[stackbuf_size];
char *buf = stackbuf;
char *buffer = NULL;
@@ -85,15 +83,14 @@ areadlinkat_with_size (int fd, char const *file, size_t size)
return NULL;
}
r = readlinkat (fd, file, buf, buf_size);
link_length = r;
ssize_t r = readlinkat (fd, file, buf, buf_size);
if (r < 0)
{
free (buffer);
return NULL;
}
size_t link_length = r;
if (link_length < buf_size)
{
buf[link_length] = 0;
+10 -10
View File
@@ -80,12 +80,11 @@ ptrdiff_t
argmatch (const char *arg, const char *const *arglist,
const void *vallist, size_t valsize)
{
size_t arglen; /* Length of ARG. */
size_t arglen = strlen (arg); /* Length of ARG. */
ptrdiff_t matchind = -1; /* Index of first nonexact match. */
bool ambiguous = false; /* If true, multiple nonexact match(es). */
arglen = strlen (arg);
/* Test all elements for either exact match or abbreviated matches. */
for (size_t i = 0; arglist[i]; i++)
{
@@ -187,7 +186,6 @@ __xargmatch_internal (const char *context,
bool allow_abbreviation)
{
ptrdiff_t res;
if (allow_abbreviation)
res = argmatch (arg, arglist, vallist, valsize);
else
@@ -262,18 +260,20 @@ static const enum backup_type backup_vals[] =
int
main (int argc, const char *const *argv)
{
const char *cp;
enum backup_type backup_type = no_backups;
if (argc > 2)
{
fprintf (stderr, "Usage: %s [VERSION_CONTROL]\n", getprogname ());
exit (1);
}
if ((cp = getenv ("VERSION_CONTROL")))
backup_type = XARGMATCH ("$VERSION_CONTROL", cp,
backup_args, backup_vals);
enum backup_type backup_type = no_backups;
{
const char *cp;
if ((cp = getenv ("VERSION_CONTROL")))
backup_type = XARGMATCH ("$VERSION_CONTROL", cp,
backup_args, backup_vals);
}
if (argc == 2)
backup_type = XARGMATCH (getprogname (), argv[1],
+7 -11
View File
@@ -57,9 +57,8 @@ argp_fmtstream_t
__argp_make_fmtstream (FILE *stream,
size_t lmargin, size_t rmargin, ssize_t wmargin)
{
argp_fmtstream_t fs;
fs = (struct argp_fmtstream *) malloc (sizeof (struct argp_fmtstream));
argp_fmtstream_t fs =
(struct argp_fmtstream *) malloc (sizeof (struct argp_fmtstream));
if (fs != NULL)
{
fs->stream = stream;
@@ -120,8 +119,7 @@ weak_alias (__argp_fmtstream_free, argp_fmtstream_free)
void
__argp_fmtstream_update (argp_fmtstream_t fs)
{
char *buf, *nl;
size_t len;
char *buf;
/* Scan the buffer for newlines. */
buf = fs->buf + fs->point_offs;
@@ -159,8 +157,8 @@ __argp_fmtstream_update (argp_fmtstream_t fs)
fs->point_col = pad;
}
len = fs->p - buf;
nl = memchr (buf, '\n', len);
size_t len = fs->p - buf;
char *nl = memchr (buf, '\n', len);
if (fs->point_col < 0)
fs->point_col = 0;
@@ -351,11 +349,10 @@ __argp_fmtstream_ensure (struct argp_fmtstream *fs, size_t amount)
{
if ((size_t) (fs->end - fs->p) < amount)
{
ssize_t wrote;
/* Flush FS's buffer. */
__argp_fmtstream_update (fs);
ssize_t wrote;
#ifdef _LIBC
__fxprintf (fs->stream, "%.*s", (int) (fs->p - fs->buf), fs->buf);
wrote = fs->p - fs->buf;
@@ -406,11 +403,10 @@ __argp_fmtstream_printf (struct argp_fmtstream *fs, const char *fmt, ...)
do
{
va_list args;
if (! __argp_fmtstream_ensure (fs, size_guess))
return -1;
va_list args;
va_start (args, fmt);
avail = fs->end - fs->p;
out = __vsnprintf (fs->p, avail, fmt, args);
+3 -6
View File
@@ -242,10 +242,9 @@ __argp_fmtstream_putc (argp_fmtstream_t __fs, int __ch)
ARGP_FS_EI size_t
__argp_fmtstream_set_lmargin (argp_fmtstream_t __fs, size_t __lmargin)
{
size_t __old;
if ((size_t) (__fs->p - __fs->buf) > __fs->point_offs)
__argp_fmtstream_update (__fs);
__old = __fs->lmargin;
size_t __old = __fs->lmargin;
__fs->lmargin = __lmargin;
return __old;
}
@@ -254,10 +253,9 @@ __argp_fmtstream_set_lmargin (argp_fmtstream_t __fs, size_t __lmargin)
ARGP_FS_EI size_t
__argp_fmtstream_set_rmargin (argp_fmtstream_t __fs, size_t __rmargin)
{
size_t __old;
if ((size_t) (__fs->p - __fs->buf) > __fs->point_offs)
__argp_fmtstream_update (__fs);
__old = __fs->rmargin;
size_t __old = __fs->rmargin;
__fs->rmargin = __rmargin;
return __old;
}
@@ -266,10 +264,9 @@ __argp_fmtstream_set_rmargin (argp_fmtstream_t __fs, size_t __rmargin)
ARGP_FS_EI size_t
__argp_fmtstream_set_wmargin (argp_fmtstream_t __fs, size_t __wmargin)
{
size_t __old;
if ((size_t) (__fs->p - __fs->buf) > __fs->point_offs)
__argp_fmtstream_update (__fs);
__old = __fs->wmargin;
size_t __old = __fs->wmargin;
__fs->wmargin = __wmargin;
return __old;
}
+191 -158
View File
@@ -136,9 +136,9 @@ static const struct uparam_name uparam_names[] =
static void
validate_uparams (const struct argp_state *state, struct uparams *upptr)
{
const struct uparam_name *up;
for (up = uparam_names; up < uparam_names + nuparam_names; up++)
for (const struct uparam_name *up = uparam_names;
up < uparam_names + nuparam_names;
up++)
{
if (!(up->is_bool
|| up->uparams_offs == offsetof (struct uparams, rmargin)))
@@ -175,17 +175,15 @@ fill_in_uparams (const struct argp_state *state)
if (isalpha ((unsigned char) *var))
{
size_t var_len;
const struct uparam_name *un;
int unspec = 0, val = 0;
const char *arg = var;
while (isalnum ((unsigned char) *arg) || *arg == '-' || *arg == '_')
arg++;
var_len = arg - var;
size_t var_len = arg - var;
SKIPWS (arg);
int unspec = 0;
if (*arg == '\0' || *arg == ',')
unspec = 1;
else if (*arg == '=')
@@ -194,6 +192,7 @@ fill_in_uparams (const struct argp_state *state)
SKIPWS (arg);
}
int val = 0;
if (unspec)
{
if (var[0] == 'n' && var[1] == 'o' && var[2] == '-')
@@ -213,6 +212,7 @@ fill_in_uparams (const struct argp_state *state)
SKIPWS (arg);
}
const struct uparam_name *un;
for (un = uparam_names;
un < uparam_names + nuparam_names;
un++)
@@ -438,18 +438,12 @@ struct hol
static struct hol *
make_hol (const struct argp *argp, struct hol_cluster *cluster)
{
char *so;
const struct argp_option *o;
const struct argp_option *opts = argp->options;
struct hol_entry *entry;
unsigned num_short_options = 0;
struct hol *hol = malloc (sizeof (struct hol));
assert (hol);
hol->num_entries = 0;
hol->clusters = NULL;
const struct argp_option *opts = argp->options;
if (opts)
{
int cur_group = 0;
@@ -458,7 +452,8 @@ make_hol (const struct argp *argp, struct hol_cluster *cluster)
assert (! oalias (opts));
/* Calculate the space needed. */
for (o = opts; ! oend (o); o++)
unsigned num_short_options = 0;
for (const struct argp_option *o = opts; ! oend (o); o++)
{
if (! oalias (o))
hol->num_entries++;
@@ -474,7 +469,9 @@ make_hol (const struct argp *argp, struct hol_cluster *cluster)
assert (hol->num_entries <= SIZE_MAX / sizeof (struct hol_entry));
/* Fill in the entries. */
so = hol->short_options;
char *so = hol->short_options;
const struct argp_option *o;
struct hol_entry *entry;
for (o = opts, entry = hol->entries; ! oend (o); entry++)
{
entry->opt = o;
@@ -534,7 +531,6 @@ static void
hol_free (struct hol *hol)
{
struct hol_cluster *cl = hol->clusters;
while (cl)
{
struct hol_cluster *next = cl->next;
@@ -561,11 +557,12 @@ hol_entry_short_iterate (const struct hol_entry *entry,
const char *domain, void *cookie),
const char *domain, void *cookie)
{
unsigned nopts;
int val = 0;
const struct argp_option *opt, *real = entry->opt;
const struct argp_option *real = entry->opt;
char *so = entry->short_options;
int val = 0;
const struct argp_option *opt;
unsigned nopts;
for (opt = real, nopts = entry->num; nopts > 0 && !val; opt++, nopts--)
if (oshort (opt) && *so == opt->key)
{
@@ -592,10 +589,11 @@ hol_entry_long_iterate (const struct hol_entry *entry,
const char *domain, void *cookie),
const char *domain, void *cookie)
{
unsigned nopts;
int val = 0;
const struct argp_option *opt, *real = entry->opt;
const struct argp_option *real = entry->opt;
int val = 0;
const struct argp_option *opt;
unsigned nopts;
for (opt = real, nopts = entry->num; nopts > 0 && !val; opt++, nopts--)
if (opt->name)
{
@@ -629,8 +627,8 @@ static const char *
hol_entry_first_long (const struct hol_entry *entry)
{
const struct argp_option *opt;
unsigned num;
for (opt = entry->opt, num = entry->num; num > 0; opt++, num--)
unsigned nopts;
for (opt = entry->opt, nopts = entry->num; nopts > 0; opt++, nopts--)
if (opt->name && ovisible (opt))
return opt->name;
return NULL;
@@ -781,12 +779,11 @@ hol_cluster_base (struct hol_cluster *cl)
static int
canon_doc_option (const char **name)
{
int non_opt;
/* Skip initial whitespace. */
while (isspace ((unsigned char) **name))
(*name)++;
/* Decide whether this looks like an option (leading '-') or not. */
non_opt = (**name != '-');
int non_opt = (**name != '-');
/* Skip until part of name used for sorting. */
while (**name && !isalnum ((unsigned char) **name))
(*name)++;
@@ -957,15 +954,13 @@ hol_append (struct hol *hol, struct hol *more)
more->num_entries = 0; /* Mark MORE's fields as invalid. */
}
else
/* Append the entries in MORE to those in HOL, taking care to only add
non-shadowed SHORT_OPTIONS values. */
{
unsigned left;
char *so, *more_so;
struct hol_entry *e;
/* Append the entries in MORE to those in HOL, taking care to only add
non-shadowed SHORT_OPTIONS values. */
unsigned num_entries = hol->num_entries + more->num_entries;
struct hol_entry *entries =
malloc (num_entries * sizeof (struct hol_entry));
unsigned hol_so_len = strlen (hol->short_options);
char *short_options =
malloc (hol_so_len + strlen (more->short_options) + 1);
@@ -982,21 +977,22 @@ hol_append (struct hol *hol, struct hol *more)
__mempcpy (short_options, hol->short_options, hol_so_len);
/* Fix up the short options pointers from HOL. */
struct hol_entry *e;
unsigned left;
for (e = entries, left = hol->num_entries; left > 0; e++, left--)
e->short_options
= short_options + (e->short_options - hol->short_options);
/* Now add the short options from MORE, fixing up its entries
too. */
so = short_options + hol_so_len;
more_so = more->short_options;
char *so = short_options + hol_so_len;
char *more_so = more->short_options;
for (left = more->num_entries; left > 0; e++, left--)
{
int opts_left;
const struct argp_option *opt;
e->short_options = so;
int opts_left;
const struct argp_option *opt;
for (opts_left = e->num, opt = e->opt; opts_left; opt++, opts_left--)
{
int ch = *more_so;
@@ -1032,8 +1028,9 @@ hol_append (struct hol *hol, struct hol *more)
static struct hol *
argp_hol (const struct argp *argp, struct hol_cluster *cluster)
{
const struct argp_child *child = argp->children;
struct hol *hol = make_hol (argp, cluster);
const struct argp_child *child = argp->children;
if (child)
while (child->argp)
{
@@ -1227,51 +1224,64 @@ static void
hol_entry_help (struct hol_entry *entry, const struct argp_state *state,
argp_fmtstream_t stream, struct hol_help_state *hhstate)
{
unsigned num;
const struct argp_option *real = entry->opt, *opt;
char *so = entry->short_options;
int have_long_opt = 0; /* We have any long options. */
/* Saved margins. */
int old_lm = __argp_fmtstream_set_lmargin (stream, 0);
int old_wm = __argp_fmtstream_wmargin (stream);
/* PEST is a state block holding some of our variables that we'd like to
share with helper functions. */
struct pentry_state pest = { entry, stream, hhstate, 1, state };
const struct argp_option *real = entry->opt;
int have_long_opt = 0; /* We have any long options. */
if (! odoc (real))
for (opt = real, num = entry->num; num > 0; opt++, num--)
if (opt->name && ovisible (opt))
{
have_long_opt = 1;
break;
}
{
const struct argp_option *opt;
unsigned num;
for (opt = real, num = entry->num; num > 0; opt++, num--)
if (opt->name && ovisible (opt))
{
have_long_opt = 1;
break;
}
}
/* First emit short options. */
__argp_fmtstream_set_wmargin (stream, uparams.short_opt_col); /* For truly bizarre cases. */
for (opt = real, num = entry->num; num > 0; opt++, num--)
if (oshort (opt) && opt->key == *so)
/* OPT has a valid (non shadowed) short option. */
{
if (ovisible (opt))
{
comma (uparams.short_opt_col, &pest);
__argp_fmtstream_putc (stream, '-');
__argp_fmtstream_putc (stream, *so);
if (!have_long_opt || uparams.dup_args)
arg (real, " %s", "[%s]",
state == NULL ? NULL : state->root_argp->argp_domain,
stream);
else if (real->arg)
hhstate->suppressed_dup_arg = 1;
}
so++;
}
{
__argp_fmtstream_set_wmargin (stream, uparams.short_opt_col); /* For truly bizarre cases. */
char *so = entry->short_options;
const struct argp_option *opt;
unsigned num;
for (opt = real, num = entry->num; num > 0; opt++, num--)
if (oshort (opt) && opt->key == *so)
/* OPT has a valid (non shadowed) short option. */
{
if (ovisible (opt))
{
comma (uparams.short_opt_col, &pest);
__argp_fmtstream_putc (stream, '-');
__argp_fmtstream_putc (stream, *so);
if (!have_long_opt || uparams.dup_args)
arg (real, " %s", "[%s]",
state == NULL ? NULL : state->root_argp->argp_domain,
stream);
else if (real->arg)
hhstate->suppressed_dup_arg = 1;
}
so++;
}
}
/* Now, long options. */
if (odoc (real))
/* A "documentation" option. */
{
__argp_fmtstream_set_wmargin (stream, uparams.doc_opt_col);
const struct argp_option *opt;
unsigned num;
for (opt = real, num = entry->num; num > 0; opt++, num--)
if (opt->name && ovisible (opt))
{
@@ -1289,6 +1299,9 @@ hol_entry_help (struct hol_entry *entry, const struct argp_state *state,
/* A real long option. */
{
__argp_fmtstream_set_wmargin (stream, uparams.long_opt_col);
const struct argp_option *opt;
unsigned num;
for (opt = real, num = entry->num; num > 0; opt++, num--)
if (opt->name && ovisible (opt))
{
@@ -1354,12 +1367,14 @@ static void
hol_help (struct hol *hol, const struct argp_state *state,
argp_fmtstream_t stream)
{
unsigned num;
struct hol_entry *entry;
struct hol_help_state hhstate = { NULL, 0, 0 };
for (entry = hol->entries, num = hol->num_entries; num > 0; entry++, num--)
hol_entry_help (entry, state, stream, &hhstate);
{
struct hol_entry *entry;
unsigned num;
for (entry = hol->entries, num = hol->num_entries; num > 0; entry++, num--)
hol_entry_help (entry, state, stream, &hhstate);
}
if (hhstate.suppressed_dup_arg && uparams.dup_args_note)
{
@@ -1404,24 +1419,27 @@ usage_argful_short_opt (const struct argp_option *opt,
const char *domain, void *cookie)
{
argp_fmtstream_t stream = cookie;
const char *arg = opt->arg;
int flags = opt->flags | real->flags;
const char *arg = opt->arg;
if (! arg)
arg = real->arg;
if (arg && !(flags & OPTION_NO_USAGE))
if (arg)
{
arg = dgettext (domain, arg);
if (flags & OPTION_ARG_OPTIONAL)
__argp_fmtstream_printf (stream, " [-%c[%s]]", opt->key, arg);
else
int flags = opt->flags | real->flags;
if (!(flags & OPTION_NO_USAGE))
{
/* Manually do line wrapping so that it (probably) won't
get wrapped at the embedded space. */
space (stream, 6 + strlen (arg));
__argp_fmtstream_printf (stream, "[-%c %s]", opt->key, arg);
arg = dgettext (domain, arg);
if (flags & OPTION_ARG_OPTIONAL)
__argp_fmtstream_printf (stream, " [-%c[%s]]", opt->key, arg);
else
{
/* Manually do line wrapping so that it (probably) won't
get wrapped at the embedded space. */
space (stream, 6 + strlen (arg));
__argp_fmtstream_printf (stream, "[-%c %s]", opt->key, arg);
}
}
}
@@ -1436,12 +1454,12 @@ usage_long_opt (const struct argp_option *opt,
const char *domain, void *cookie)
{
argp_fmtstream_t stream = cookie;
const char *arg = opt->arg;
int flags = opt->flags | real->flags;
const char *arg = opt->arg;
if (! arg)
arg = real->arg;
int flags = opt->flags | real->flags;
if (! (flags & OPTION_NO_USAGE))
{
if (arg)
@@ -1465,17 +1483,19 @@ hol_usage (struct hol *hol, argp_fmtstream_t stream)
{
if (hol->num_entries > 0)
{
unsigned nentries;
struct hol_entry *entry;
char *short_no_arg_opts = alloca (strlen (hol->short_options) + 1);
char *snao_end = short_no_arg_opts;
/* First we put a list of short options without arguments. */
for (entry = hol->entries, nentries = hol->num_entries
; nentries > 0
; entry++, nentries--)
hol_entry_short_iterate (entry, add_argless_short_opt,
entry->argp->argp_domain, &snao_end);
{
struct hol_entry *entry;
unsigned nentries;
for (entry = hol->entries, nentries = hol->num_entries
; nentries > 0
; entry++, nentries--)
hol_entry_short_iterate (entry, add_argless_short_opt,
entry->argp->argp_domain, &snao_end);
}
if (snao_end > short_no_arg_opts)
{
*snao_end++ = '\0';
@@ -1483,18 +1503,26 @@ hol_usage (struct hol *hol, argp_fmtstream_t stream)
}
/* Now a list of short options *with* arguments. */
for (entry = hol->entries, nentries = hol->num_entries
; nentries > 0
; entry++, nentries--)
hol_entry_short_iterate (entry, usage_argful_short_opt,
entry->argp->argp_domain, stream);
{
struct hol_entry *entry;
unsigned nentries;
for (entry = hol->entries, nentries = hol->num_entries
; nentries > 0
; entry++, nentries--)
hol_entry_short_iterate (entry, usage_argful_short_opt,
entry->argp->argp_domain, stream);
}
/* Finally, a list of long options (whew!). */
for (entry = hol->entries, nentries = hol->num_entries
; nentries > 0
; entry++, nentries--)
hol_entry_long_iterate (entry, usage_long_opt,
entry->argp->argp_domain, stream);
{
struct hol_entry *entry;
unsigned nentries;
for (entry = hol->entries, nentries = hol->num_entries
; nentries > 0
; entry++, nentries--)
hol_entry_long_iterate (entry, usage_long_opt,
entry->argp->argp_domain, stream);
}
}
}
@@ -1504,11 +1532,11 @@ static size_t
argp_args_levels (const struct argp *argp)
{
size_t levels = 0;
const struct argp_child *child = argp->children;
if (argp->args_doc && strchr (argp->args_doc, '\n'))
levels++;
const struct argp_child *child = argp->children;
if (child)
while (child->argp)
levels += argp_args_levels ((child++)->argp);
@@ -1527,39 +1555,43 @@ argp_args_usage (const struct argp *argp, const struct argp_state *state,
{
char *our_level = *levels;
int multiple = 0;
const struct argp_child *child = argp->children;
const char *tdoc =
argp->args_doc ? dgettext (argp->argp_domain, argp->args_doc) : NULL;
const char *fdoc = filter_doc (tdoc, ARGP_KEY_HELP_ARGS_DOC, argp, state);
const char *nl = NULL;
if (fdoc)
{
const char *cp = fdoc;
nl = __strchrnul (cp, '\n');
if (*nl != '\0')
/* This is a 'multi-level' args doc; advance to the correct position
as determined by our state in LEVELS, and update LEVELS. */
{
int i;
multiple = 1;
for (i = 0; i < *our_level; i++)
cp = nl + 1, nl = __strchrnul (cp, '\n');
(*levels)++;
}
{
const char *tdoc =
argp->args_doc ? dgettext (argp->argp_domain, argp->args_doc) : NULL;
const char *fdoc = filter_doc (tdoc, ARGP_KEY_HELP_ARGS_DOC, argp, state);
/* Manually do line wrapping so that it (probably) won't get wrapped at
any embedded spaces. */
space (stream, 1 + nl - cp);
if (fdoc)
{
const char *cp = fdoc;
nl = __strchrnul (cp, '\n');
if (*nl != '\0')
/* This is a 'multi-level' args doc; advance to the correct position
as determined by our state in LEVELS, and update LEVELS. */
{
multiple = 1;
for (int i = 0; i < *our_level; i++)
cp = nl + 1, nl = __strchrnul (cp, '\n');
(*levels)++;
}
__argp_fmtstream_write (stream, cp, nl - cp);
}
if (fdoc && fdoc != tdoc)
free ((char *)fdoc); /* Free user's modified doc string. */
/* Manually do line wrapping so that it (probably) won't get wrapped at
any embedded spaces. */
space (stream, 1 + nl - cp);
if (child)
while (child->argp)
advance = !argp_args_usage ((child++)->argp, state, levels, advance, stream);
__argp_fmtstream_write (stream, cp, nl - cp);
}
if (fdoc && fdoc != tdoc)
free ((char *)fdoc); /* Free user's modified doc string. */
}
{
const struct argp_child *child = argp->children;
if (child)
while (child->argp)
advance = !argp_args_usage ((child++)->argp, state, levels, advance, stream);
}
if (advance && multiple)
{
@@ -1590,23 +1622,23 @@ argp_doc (const struct argp *argp, const struct argp_state *state,
int post, int pre_blank, int first_only,
argp_fmtstream_t stream)
{
const char *text;
const char *inp_text;
void *input = NULL;
int anything = 0;
size_t inp_text_limit = 0;
const char *doc = argp->doc ? dgettext (argp->argp_domain, argp->doc) : NULL;
const struct argp_child *child = argp->children;
if (doc)
{
char const *vt = strchr (doc, '\v');
inp_text = post ? (vt ? vt + 1 : NULL) : doc;
inp_text_limit = (!post && vt) ? (vt - doc) : 0;
}
else
inp_text = NULL;
{
const char *doc = argp->doc ? dgettext (argp->argp_domain, argp->doc) : NULL;
if (doc)
{
char const *vt = strchr (doc, '\v');
inp_text = post ? (vt ? vt + 1 : NULL) : doc;
inp_text_limit = (!post && vt) ? (vt - doc) : 0;
}
else
inp_text = NULL;
}
const char *text;
void *input = NULL;
if (argp->help_filter)
/* We have to filter the doc strings. */
{
@@ -1623,6 +1655,7 @@ argp_doc (const struct argp *argp, const struct argp_state *state,
else
text = (const char *) inp_text;
int anything = 0;
if (text)
{
if (pre_blank)
@@ -1661,12 +1694,15 @@ argp_doc (const struct argp *argp, const struct argp_state *state,
}
}
if (child)
while (child->argp && !(first_only && anything))
anything |=
argp_doc ((child++)->argp, state,
post, anything || pre_blank, first_only,
stream);
{
const struct argp_child *child = argp->children;
if (child)
while (child->argp && !(first_only && anything))
anything |=
argp_doc ((child++)->argp, state,
post, anything || pre_blank, first_only,
stream);
}
return anything;
}
@@ -1679,10 +1715,6 @@ static void
_help (const struct argp *argp, const struct argp_state *state, FILE *stream,
unsigned flags, char *name)
{
int anything = 0; /* Whether we've output anything. */
struct hol *hol = NULL;
argp_fmtstream_t fs;
if (! stream)
return;
@@ -1693,7 +1725,7 @@ _help (const struct argp *argp, const struct argp_state *state, FILE *stream,
if (! uparams.valid)
fill_in_uparams (state);
fs = __argp_make_fmtstream (stream, 0, uparams.rmargin, 0);
argp_fmtstream_t fs = __argp_make_fmtstream (stream, 0, uparams.rmargin, 0);
if (! fs)
{
#if _LIBC || (HAVE_FLOCKFILE && HAVE_FUNLOCKFILE)
@@ -1702,6 +1734,7 @@ _help (const struct argp *argp, const struct argp_state *state, FILE *stream,
return;
}
struct hol *hol = NULL;
if (flags & (ARGP_HELP_USAGE | ARGP_HELP_SHORT_USAGE | ARGP_HELP_LONG))
{
hol = argp_hol (argp, NULL);
@@ -1713,6 +1746,7 @@ _help (const struct argp *argp, const struct argp_state *state, FILE *stream,
hol_sort (hol);
}
int anything = 0; /* Whether we've output anything. */
if (flags & (ARGP_HELP_USAGE | ARGP_HELP_SHORT_USAGE))
/* Print a short "Usage:" message. */
{
@@ -1884,12 +1918,11 @@ __argp_error (const struct argp_state *state, const char *fmt, ...)
if (stream)
{
va_list ap;
#if _LIBC || (HAVE_FLOCKFILE && HAVE_FUNLOCKFILE)
__flockfile (stream);
#endif
va_list ap;
va_start (ap, fmt);
#ifdef _LIBC
@@ -1960,8 +1993,8 @@ __argp_failure (const struct argp_state *state, int status, int errnum,
if (fmt)
{
va_list ap;
va_start (ap, fmt);
#ifdef _LIBC
char *buf;
+53 -60
View File
@@ -225,12 +225,11 @@ group_parse (struct group *group, struct argp_state *state, int key, char *arg)
{
if (group->parser)
{
error_t err;
state->hook = group->hook;
state->input = group->input;
state->child_inputs = group->child_inputs;
state->arg_num = group->args_processed;
err = (*group->parser)(key, arg, state);
error_t err = (*group->parser)(key, arg, state);
group->hook = state->hook;
return err;
}
@@ -458,16 +457,7 @@ static error_t
parser_init (struct parser *parser, const struct argp *argp,
int argc, char **argv, int flags, void *input)
{
error_t err = 0;
struct group *group;
struct parser_sizes szs;
struct _getopt_data opt_data = _GETOPT_DATA_INITIALIZER;
char *storage;
size_t glen, gsum;
size_t clen, csum;
size_t llen, lsum;
size_t slen, ssum;
szs.short_len = (flags & ARGP_NO_ARGS) ? 0 : 1;
szs.long_len = 0;
szs.num_groups = 0;
@@ -477,31 +467,34 @@ parser_init (struct parser *parser, const struct argp *argp,
calc_sizes (argp, &szs);
/* Lengths of the various bits of storage used by PARSER. */
glen = (szs.num_groups + 1) * sizeof (struct group);
clen = szs.num_child_inputs * sizeof (void *);
llen = (szs.long_len + 1) * sizeof (struct option);
slen = szs.short_len + 1;
size_t glen = (szs.num_groups + 1) * sizeof (struct group);
size_t clen = szs.num_child_inputs * sizeof (void *);
size_t llen = (szs.long_len + 1) * sizeof (struct option);
size_t slen = szs.short_len + 1;
/* Sums of previous lengths, properly aligned. There's no need to
align gsum, since struct group is aligned at least as strictly as
void * (since it contains a void * member). And there's no need
to align lsum, since struct option is aligned at least as
strictly as char. */
gsum = glen;
csum = alignto (gsum + clen, alignof (struct option));
lsum = csum + llen;
ssum = lsum + slen;
size_t gsum = glen;
size_t csum = alignto (gsum + clen, alignof (struct option));
size_t lsum = csum + llen;
size_t ssum = lsum + slen;
parser->storage = malloc (ssum);
if (! parser->storage)
return ENOMEM;
storage = parser->storage;
char *storage = parser->storage;
parser->groups = parser->storage;
parser->child_inputs = (void **) (storage + gsum);
parser->long_opts = (struct option *) (storage + csum);
parser->short_opts = storage + lsum;
parser->opt_data = opt_data;
{
struct _getopt_data opt_data = _GETOPT_DATA_INITIALIZER;
parser->opt_data = opt_data;
}
memset (parser->child_inputs, 0, clen);
parser_convert (parser, argp, flags);
@@ -522,28 +515,32 @@ parser_init (struct parser *parser, const struct argp *argp,
values to child parsers. */
if (parser->groups < parser->egroup)
parser->groups->input = input;
for (group = parser->groups;
group < parser->egroup && (!err || err == EBADKEY);
group++)
{
if (group->parent)
/* If a child parser, get the initial input value from the parent. */
group->input = group->parent->child_inputs[group->parent_index];
{
error_t err = 0;
if (!group->parser
&& group->argp->children && group->argp->children->argp)
/* For the special case where no parsing function is supplied for an
argp, propagate its input to its first child, if any (this just
makes very simple wrapper argps more convenient). */
group->child_inputs[0] = group->input;
for (struct group *group = parser->groups;
group < parser->egroup && (!err || err == EBADKEY);
group++)
{
if (group->parent)
/* If a child parser, get the initial input value from the parent. */
group->input = group->parent->child_inputs[group->parent_index];
err = group_parse (group, &parser->state, ARGP_KEY_INIT, NULL);
}
if (err == EBADKEY)
err = 0; /* Some parser didn't understand. */
if (!group->parser
&& group->argp->children && group->argp->children->argp)
/* For the special case where no parsing function is supplied for an
argp, propagate its input to its first child, if any (this just
makes very simple wrapper argps more convenient). */
group->child_inputs[0] = group->input;
if (err)
return err;
err = group_parse (group, &parser->state, ARGP_KEY_INIT, NULL);
}
if (err == EBADKEY)
err = 0; /* Some parser didn't understand. */
if (err)
return err;
}
if (parser->state.flags & ARGP_NO_ERRS)
{
@@ -570,8 +567,6 @@ static error_t
parser_finalize (struct parser *parser,
error_t err, int arg_ebadkey, int *end_index)
{
struct group *group;
if (err == EBADKEY && arg_ebadkey)
/* Suppress errors generated by unparsed arguments. */
err = 0;
@@ -582,12 +577,12 @@ parser_finalize (struct parser *parser,
/* We successfully parsed all arguments! Call all the parsers again,
just a few more times... */
{
for (group = parser->groups;
for (struct group *group = parser->groups;
group < parser->egroup && (!err || err==EBADKEY);
group++)
if (group->args_processed == 0)
err = group_parse (group, &parser->state, ARGP_KEY_NO_ARGS, NULL);
for (group = parser->egroup - 1;
for (struct group *group = parser->egroup - 1;
group >= parser->groups && (!err || err==EBADKEY);
group--)
err = group_parse (group, &parser->state, ARGP_KEY_END, NULL);
@@ -628,7 +623,7 @@ parser_finalize (struct parser *parser,
ARGP_HELP_STD_ERR);
/* Since we didn't exit, give each parser an error indication. */
for (group = parser->groups; group < parser->egroup; group++)
for (struct group *group = parser->groups; group < parser->egroup; group++)
group_parse (group, &parser->state, ARGP_KEY_ERROR, NULL);
}
else
@@ -637,7 +632,7 @@ parser_finalize (struct parser *parser,
/* We pass over the groups in reverse order so that child groups are
given a chance to do there processing before passing back a value to
the parent. */
for (group = parser->egroup - 1
for (struct group *group = parser->egroup - 1
; group >= parser->groups && (!err || err == EBADKEY)
; group--)
err = group_parse (group, &parser->state, ARGP_KEY_SUCCESS, NULL);
@@ -646,7 +641,7 @@ parser_finalize (struct parser *parser,
}
/* Call parsers once more, to do any final cleanup. Errors are ignored. */
for (group = parser->egroup - 1; group >= parser->groups; group--)
for (struct group *group = parser->egroup - 1; group >= parser->groups; group--)
group_parse (group, &parser->state, ARGP_KEY_FINI, NULL);
if (err == EBADKEY)
@@ -780,9 +775,6 @@ parser_parse_opt (struct parser *parser, int opt, char *val)
static error_t
parser_parse_next (struct parser *parser, int *arg_ebadkey)
{
int opt;
error_t err;
if (parser->state.quoted && parser->state.next < parser->state.quoted)
/* The next argument pointer has been moved to before the quoted
region, so pretend we never saw the quoting "--", and give getopt
@@ -790,6 +782,7 @@ parser_parse_next (struct parser *parser, int *arg_ebadkey)
process it again. */
parser->state.quoted = 0;
int opt;
if (parser->try_getopt && !parser->state.quoted)
/* Give getopt a chance to parse this. */
{
@@ -851,6 +844,7 @@ parser_parse_next (struct parser *parser, int *arg_ebadkey)
}
}
error_t err;
if (opt == KEY_ARG)
/* A non-option argument; try each parser in turn. */
err = parser_parse_arg (parser, parser->opt_data.optarg);
@@ -872,13 +866,6 @@ error_t
__argp_parse (const struct argp *argp, int argc, char **argv, unsigned flags,
int *end_index, void *input)
{
error_t err;
struct parser parser;
/* If true, then err == EBADKEY is a result of a non-option argument failing
to be parsed (which in some cases isn't actually an error). */
int arg_ebadkey = 0;
#ifndef _LIBC
if (!(flags & ARGP_PARSE_ARGV0))
{
@@ -917,11 +904,16 @@ __argp_parse (const struct argp *argp, int argc, char **argv, unsigned flags,
}
/* Construct a parser for these arguments. */
err = parser_init (&parser, argp, argc, argv, flags, input);
struct parser parser;
error_t err = parser_init (&parser, argp, argc, argv, flags, input);
if (! err)
/* Parse! */
{
/* If true, then err == EBADKEY is a result of a non-option argument
failing to be parsed (which in some cases isn't actually an error). */
int arg_ebadkey = 0;
while (! err)
err = parser_parse_next (&parser, &arg_ebadkey);
err = parser_finalize (&parser, err, arg_ebadkey, end_index);
@@ -940,10 +932,11 @@ __argp_input (const struct argp *argp, const struct argp_state *state)
{
if (state)
{
struct group *group;
struct parser *parser = state->pstate;
for (group = parser->groups; group < parser->egroup; group++)
for (struct group *group = parser->groups;
group < parser->egroup;
group++)
if (group->argp == argp)
return group->input;
}
+59 -62
View File
@@ -59,15 +59,12 @@ argz_add_sep (char **argz, size_t *argz_len, const char *string, int delim)
if (nlen > 1)
{
const char *rp;
char *wp;
*argz = (char *) realloc (*argz, *argz_len + nlen);
if (*argz == NULL)
return ENOMEM;
wp = *argz + *argz_len;
rp = string;
char *wp = *argz + *argz_len;
const char *rp = string;
do
if (*rp == delim)
{
@@ -95,15 +92,12 @@ argz_create_sep (const char *string, int delim, char **argz, size_t *len)
if (nlen > 1)
{
const char *rp;
char *wp;
*argz = (char *) malloc (nlen);
if (*argz == NULL)
return ENOMEM;
rp = string;
wp = *argz;
const char *rp = string;
char *wp = *argz;
do
if (*rp == delim)
{
@@ -250,8 +244,6 @@ error_t
argz_create (char *const argv[], char **argz, size_t *len)
{
size_t tlen = 0;
char *const *ap;
char *p;
for (int argc = 0; argv[argc] != NULL; ++argc)
tlen += strlen (argv[argc]) + 1;
@@ -264,6 +256,8 @@ argz_create (char *const argv[], char **argz, size_t *len)
if (*argz == NULL)
return ENOMEM;
char *p;
char *const *ap;
for (p = *argz, ap = argv; *ap; ++ap, ++p)
p = stpcpy (p, *ap);
}
@@ -325,7 +319,6 @@ argz_replace (char **argz, size_t *argz_len, const char *str, const char *with,
if (str && *str)
{
char *arg = 0;
char *src = *argz;
size_t src_len = *argz_len;
char *dst = 0;
@@ -333,58 +326,62 @@ argz_replace (char **argz, size_t *argz_len, const char *str, const char *with,
int delayed_copy = 1; /* True while we've avoided copying anything. */
size_t str_len = strlen (str), with_len = strlen (with);
while (!err && (arg = argz_next (src, src_len, arg)))
{
char *match = strstr (arg, str);
if (match)
{
char *from = match + str_len;
size_t to_len = match - arg;
char *to = strndup (arg, to_len);
{
char *arg = 0;
while (to && from)
{
str_append (&to, &to_len, with, with_len);
if (to)
{
match = strstr (from, str);
if (match)
{
str_append (&to, &to_len, from, match - from);
from = match + str_len;
}
else
{
str_append (&to, &to_len, from, strlen (from));
from = 0;
}
}
}
while (!err && (arg = argz_next (src, src_len, arg)))
{
char *match = strstr (arg, str);
if (match)
{
char *from = match + str_len;
size_t to_len = match - arg;
char *to = strndup (arg, to_len);
if (to)
{
if (delayed_copy)
/* We avoided copying SRC to DST until we found a match;
now that we've done so, copy everything from the start
of SRC. */
{
if (arg > src)
err = argz_append (&dst, &dst_len, src, (arg - src));
delayed_copy = 0;
}
if (! err)
err = argz_add (&dst, &dst_len, to);
free (to);
}
else
err = ENOMEM;
while (to && from)
{
str_append (&to, &to_len, with, with_len);
if (to)
{
match = strstr (from, str);
if (match)
{
str_append (&to, &to_len, from, match - from);
from = match + str_len;
}
else
{
str_append (&to, &to_len, from, strlen (from));
from = 0;
}
}
}
if (replace_count)
(*replace_count)++;
}
else if (! delayed_copy)
err = argz_add (&dst, &dst_len, arg);
}
if (to)
{
if (delayed_copy)
/* We avoided copying SRC to DST until we found a match;
now that we've done so, copy everything from the start
of SRC. */
{
if (arg > src)
err = argz_append (&dst, &dst_len, src, (arg - src));
delayed_copy = 0;
}
if (! err)
err = argz_add (&dst, &dst_len, to);
free (to);
}
else
err = ENOMEM;
if (replace_count)
(*replace_count)++;
}
else if (! delayed_copy)
err = argz_add (&dst, &dst_len, arg);
}
}
if (! err)
{
+47 -48
View File
@@ -132,11 +132,8 @@ static const long double
long double
asinl (long double x)
{
long double y, t, p, q;
int sign;
sign = 1;
y = x;
int sign = 1;
long double y = x;
if (x < 0.0L)
{
sign = -1;
@@ -151,34 +148,36 @@ asinl (long double x)
return (x - x) / (x - x); /* asin(|x|>1) is NaN */
}
else if (y < 0.5L) /* |x| < 0.5 */
long double t;
if (y < 0.5L) /* |x| < 0.5 */
{
if (y < 0.000000000000000006938893903907228377647697925567626953125L) /* |x| < 2**-57 */
if (huge + y > one)
return y; /* return x with inexact if x!=0 */
t = x * x;
p = (((((((((pS9 * t
+ pS8) * t
+ pS7) * t
+ pS6) * t
+ pS5) * t
+ pS4) * t
+ pS3) * t
+ pS2) * t
+ pS1) * t
+ pS0) * t;
long double p = (((((((((pS9 * t
+ pS8) * t
+ pS7) * t
+ pS6) * t
+ pS5) * t
+ pS4) * t
+ pS3) * t
+ pS2) * t
+ pS1) * t
+ pS0) * t;
q = (((((((( t
+ qS8) * t
+ qS7) * t
+ qS6) * t
+ qS5) * t
+ qS4) * t
+ qS3) * t
+ qS2) * t
+ qS1) * t
+ qS0;
long double q = (((((((( t
+ qS8) * t
+ qS7) * t
+ qS6) * t
+ qS5) * t
+ qS4) * t
+ qS3) * t
+ qS2) * t
+ qS1) * t
+ qS0;
return x + x * (p / q);
}
@@ -186,29 +185,29 @@ asinl (long double x)
else if (y < 0.625) /* 0.625 */
{
t = y - 0.5625;
p = ((((((((((rS10 * t
+ rS9) * t
+ rS8) * t
+ rS7) * t
+ rS6) * t
+ rS5) * t
+ rS4) * t
+ rS3) * t
+ rS2) * t
+ rS1) * t
+ rS0) * t;
long double p = ((((((((((rS10 * t
+ rS9) * t
+ rS8) * t
+ rS7) * t
+ rS6) * t
+ rS5) * t
+ rS4) * t
+ rS3) * t
+ rS2) * t
+ rS1) * t
+ rS0) * t;
q = ((((((((( t
+ sS9) * t
+ sS8) * t
+ sS7) * t
+ sS6) * t
+ sS5) * t
+ sS4) * t
+ sS3) * t
+ sS2) * t
+ sS1) * t
+ sS0;
long double q = ((((((((( t
+ sS9) * t
+ sS8) * t
+ sS7) * t
+ sS6) * t
+ sS5) * t
+ sS4) * t
+ sS3) * t
+ sS2) * t
+ sS1) * t
+ sS0;
t = asinr5625 + p / q;
}
else
+1 -3
View File
@@ -25,10 +25,8 @@ char *
asnprintf (char *resultbuf, size_t *lengthp, const char *format, ...)
{
va_list args;
char *result;
va_start (args, format);
result = vasnprintf (resultbuf, lengthp, format, args);
char *result = vasnprintf (resultbuf, lengthp, format, args);
va_end (args);
return result;
}
+1 -3
View File
@@ -25,10 +25,8 @@ wchar_t *
asnwprintf (wchar_t *resultbuf, size_t *lengthp, const wchar_t *format, ...)
{
va_list args;
wchar_t *result;
va_start (args, format);
result = vasnwprintf (resultbuf, lengthp, format, args);
wchar_t *result = vasnwprintf (resultbuf, lengthp, format, args);
va_end (args);
return result;
}
+1 -3
View File
@@ -30,10 +30,8 @@ int
asprintf (char **resultp, const char *format, ...)
{
va_list args;
int result;
va_start (args, format);
result = vasprintf (resultp, format, args);
int result = vasprintf (resultp, format, args);
va_end (args);
return result;
}
+6 -15
View File
@@ -37,8 +37,6 @@ astrxfrm (const char *s, char *resultbuf, size_t *lengthp)
char *result; /* either == resultbuf or == tmpbuf or freshly allocated
or NULL. */
size_t allocated; /* number of bytes allocated at result */
size_t length;
if (resultbuf != NULL)
{
result = resultbuf;
@@ -49,10 +47,10 @@ astrxfrm (const char *s, char *resultbuf, size_t *lengthp)
result = NULL;
allocated = 0;
}
size_t length;
{
size_t l = strlen (s);
size_t k;
/* A call to strxfrm costs about 20 times more than a call to strdup of
the result. Therefore it is worth to try to avoid calling strxfrm
@@ -69,13 +67,10 @@ astrxfrm (const char *s, char *resultbuf, size_t *lengthp)
}
else
{
size_t new_allocated;
char *new_result;
new_allocated = 3 * l + 1;
size_t new_allocated = 3 * l + 1;
if (new_allocated < 2 * allocated)
new_allocated = 2 * allocated;
new_result = (char *) malloc (new_allocated);
char *new_result = (char *) malloc (new_allocated);
if (new_result != NULL)
{
allocated = new_allocated;
@@ -85,7 +80,7 @@ astrxfrm (const char *s, char *resultbuf, size_t *lengthp)
}
errno = 0;
k = strxfrm (result, s, allocated);
size_t k = strxfrm (result, s, allocated);
if (errno != 0)
goto fail;
if (k >= allocated)
@@ -100,11 +95,8 @@ astrxfrm (const char *s, char *resultbuf, size_t *lengthp)
}
else
{
size_t new_allocated;
char *new_result;
new_allocated = k + 1;
new_result = (char *) malloc (new_allocated);
size_t new_allocated = k + 1;
char *new_result = (char *) malloc (new_allocated);
if (new_result == NULL)
goto out_of_memory;
allocated = new_allocated;
@@ -139,7 +131,6 @@ astrxfrm (const char *s, char *resultbuf, size_t *lengthp)
else
{
char *memory = (char *) malloc (length);
if (memory == NULL)
goto out_of_memory;
memcpy (memory, result, length);
+1 -3
View File
@@ -25,10 +25,8 @@ ptrdiff_t
aszprintf (char **resultp, const char *format, ...)
{
va_list args;
ptrdiff_t result;
va_start (args, format);
result = vaszprintf (resultp, format, args);
ptrdiff_t result = vaszprintf (resultp, format, args);
va_end (args);
return result;
}
+5 -9
View File
@@ -78,12 +78,8 @@ AT_FUNC_NAME (int fd, char const *file AT_FUNC_POST_FILE_PARAM_DECLS)
errno = ENOTSUP;
return FUNC_FAIL;
#else
{
/* Be careful to choose names unlikely to conflict with
/* Be careful to choose variable names unlikely to conflict with
AT_FUNC_POST_FILE_PARAM_DECLS. */
struct saved_cwd saved_cwd;
int saved_errno;
FUNC_RESULT err;
{
char proc_buf[OPENAT_BUFFER_SIZE];
@@ -107,6 +103,7 @@ AT_FUNC_NAME (int fd, char const *file AT_FUNC_POST_FILE_PARAM_DECLS)
}
}
struct saved_cwd saved_cwd;
if (save_cwd (&saved_cwd) != 0)
openat_save_fail (errno);
if (0 <= fd && fd == saved_cwd.desc)
@@ -121,14 +118,14 @@ AT_FUNC_NAME (int fd, char const *file AT_FUNC_POST_FILE_PARAM_DECLS)
if (fchdir (fd) != 0)
{
saved_errno = errno;
int saved_errno = errno;
free_cwd (&saved_cwd);
errno = saved_errno;
return FUNC_FAIL;
}
err = CALL_FUNC (file);
saved_errno = (err == FUNC_FAIL ? errno : 0);
FUNC_RESULT err = CALL_FUNC (file);
int saved_errno = (err == FUNC_FAIL ? errno : 0);
if (restore_cwd (&saved_cwd) != 0)
openat_restore_fail (errno);
@@ -138,7 +135,6 @@ AT_FUNC_NAME (int fd, char const *file AT_FUNC_POST_FILE_PARAM_DECLS)
if (saved_errno)
errno = saved_errno;
return err;
}
#endif
}
#undef CALL_FUNC
+19 -18
View File
@@ -41,14 +41,6 @@ at_func2 (int fd1, char const *file1,
int fd2, char const *file2,
int (*func) (char const *file1, char const *file2))
{
struct saved_cwd saved_cwd;
int saved_errno;
int err;
char *file1_alt;
char *file2_alt;
struct stat st1;
struct stat st2;
/* There are 16 possible scenarios, based on whether an fd is
AT_FDCWD or real, and whether a file is absolute or relative:
@@ -125,6 +117,8 @@ at_func2 (int fd1, char const *file1,
if (fd1 == AT_FDCWD) /* Cases 3, 7. */
{
struct stat st1;
struct stat st2;
if (stat (".", &st1) == -1 || fstat (fd2, &st2) == -1)
return -1;
if (!S_ISDIR (st2.st_mode))
@@ -137,6 +131,8 @@ at_func2 (int fd1, char const *file1,
}
else if (fd2 == AT_FDCWD) /* Cases 12, 13. */
{
struct stat st1;
struct stat st2;
if (stat (".", &st2) == -1 || fstat (fd1, &st1) == -1)
return -1;
if (!S_ISDIR (st1.st_mode))
@@ -149,6 +145,8 @@ at_func2 (int fd1, char const *file1,
}
else if (fd1 != fd2) /* Case 15b. */
{
struct stat st1;
struct stat st2;
if (fstat (fd1, &st1) == -1 || fstat (fd2, &st2) == -1)
return -1;
if (!S_ISDIR (st1.st_mode) || !S_ISDIR (st2.st_mode))
@@ -165,6 +163,7 @@ at_func2 (int fd1, char const *file1,
}
else /* Case 15a. */
{
struct stat st1;
if (fstat (fd1, &st1) == -1)
return -1;
if (!S_ISDIR (st1.st_mode))
@@ -172,6 +171,7 @@ at_func2 (int fd1, char const *file1,
errno = ENOTDIR;
return -1;
}
struct stat st2;
if (stat (".", &st2) == 0 && psame_inode (&st1, &st2))
return func (file1, file2); /* Reduced to case 5. */
}
@@ -186,6 +186,7 @@ at_func2 (int fd1, char const *file1,
/* Cases 3, 7, 12, 13, 15a, 15b remain. With all reductions in
place, it is time to start changing directories. */
struct saved_cwd saved_cwd;
if (save_cwd (&saved_cwd) != 0)
openat_save_fail (errno);
@@ -193,7 +194,7 @@ at_func2 (int fd1, char const *file1,
{
if (fchdir (fd1) != 0)
{
saved_errno = errno;
int saved_errno = errno;
free_cwd (&saved_cwd);
errno = saved_errno;
return -1;
@@ -204,8 +205,8 @@ at_func2 (int fd1, char const *file1,
/* Cases 3, 7, 12, 13, 15a remain. Convert one relative name to
absolute, if necessary. */
file1_alt = (char *) file1;
file2_alt = (char *) file2;
char *file1_alt = (char *) file1;
char *file2_alt = (char *) file2;
if (fd1 == AT_FDCWD && !IS_ABSOLUTE_FILE_NAME (file1)) /* Case 7. */
{
@@ -215,7 +216,7 @@ at_func2 (int fd1, char const *file1,
char *cwd = getcwd (NULL, 0);
if (!cwd)
{
saved_errno = errno;
int saved_errno = errno;
free_cwd (&saved_cwd);
errno = saved_errno;
return -1;
@@ -223,7 +224,7 @@ at_func2 (int fd1, char const *file1,
file1_alt = mfile_name_concat (cwd, file1, NULL);
if (!file1_alt)
{
saved_errno = errno;
int saved_errno = errno;
free (cwd);
free_cwd (&saved_cwd);
errno = saved_errno;
@@ -236,7 +237,7 @@ at_func2 (int fd1, char const *file1,
char *cwd = getcwd (NULL, 0);
if (!cwd)
{
saved_errno = errno;
int saved_errno = errno;
free_cwd (&saved_cwd);
errno = saved_errno;
return -1;
@@ -244,7 +245,7 @@ at_func2 (int fd1, char const *file1,
file2_alt = mfile_name_concat (cwd, file2, NULL);
if (!file2_alt)
{
saved_errno = errno;
int saved_errno = errno;
free (cwd);
free_cwd (&saved_cwd);
errno = saved_errno;
@@ -256,7 +257,7 @@ at_func2 (int fd1, char const *file1,
/* Cases 3, 12, 15a remain. Change to the correct directory. */
if (fchdir (fd1 == AT_FDCWD ? fd2 : fd1) != 0)
{
saved_errno = errno;
int saved_errno = errno;
free_cwd (&saved_cwd);
if (file1 != file1_alt)
free (file1_alt);
@@ -268,8 +269,8 @@ at_func2 (int fd1, char const *file1,
/* Finally safe to perform the user's function, then clean up. */
err = func (file1_alt, file2_alt);
saved_errno = (err < 0 ? errno : 0);
int err = func (file1_alt, file2_alt);
int saved_errno = (err < 0 ? errno : 0);
if (file1 != file1_alt)
free (file1_alt);
+8 -9
View File
@@ -184,14 +184,11 @@ static const long double
long double
atanl (long double x)
{
int k, sign;
long double t, u, p, q;
/* Check for zero or NaN. */
if (isnanl (x) || x == 0.0)
return x + x;
sign = x < 0.0;
int sign = x < 0.0;
if (x + x == x)
{
@@ -203,8 +200,10 @@ atanl (long double x)
}
if (sign)
x = -x;
x = -x;
int k;
long double t;
if (x >= 10.25)
{
k = 83;
@@ -216,15 +215,15 @@ atanl (long double x)
Roundoff to integer is asymmetrical to avoid cancellation when t < 0
(cf. fdlibm). */
k = 8.0 * x + 0.25;
u = 0.125 * k;
long double u = 0.125 * k;
/* Small arctan argument. */
t = (x - u) / (1.0 + x * u);
}
/* Arctan of small argument t. */
u = t * t;
p = ((((p4 * u) + p3) * u + p2) * u + p1) * u + p0;
q = ((((u + q4) * u + q3) * u + q2) * u + q1) * u + q0;
long double u = t * t;
long double p = ((((p4 * u) + p3) * u + p2) * u + p1) * u + p0;
long double q = ((((u + q4) * u + q3) * u + q2) * u + q1) * u + q0;
u = t * u * p / q + t;
/* arctan x = arctan u + arctan t */
+2 -1
View File
@@ -211,7 +211,6 @@ numbered_backup (int dir_fd, char **buffer, idx_t buffer_size, idx_t filelen,
enum numbered_backup_result result = BACKUP_IS_NEW;
DIR *dirp = *dirpp;
char *buf = *buffer;
idx_t versionlenmax = 1;
idx_t baselen = filelen - base_offset;
if (dirp)
@@ -234,6 +233,8 @@ numbered_backup (int dir_fd, char **buffer, idx_t buffer_size, idx_t filelen,
*dirpp = dirp;
}
idx_t versionlenmax = 1;
for (struct dirent *dp; (dp = readdir (dirp)) != NULL; )
{
if (_D_EXACT_NAMLEN (dp) < baselen + 4)
+4 -3
View File
@@ -335,13 +335,14 @@ static bool
decode_8 (char const *restrict in, idx_t inlen,
char *restrict *outp, idx_t *outleft)
{
char *out = *outp;
if (inlen < 8)
return false;
if (!isbase32 (in[0]) || !isbase32 (in[1]))
return false;
char *out = *outp;
if (*outleft)
{
*out++ = ((base32_to_int[to_uchar (in[0])] << 3)
@@ -464,7 +465,6 @@ base32_decode_ctx (struct base32_decode_context *ctx,
const char *restrict in, idx_t inlen,
char *restrict out, idx_t *outlen)
{
idx_t outleft = *outlen;
bool ignore_newlines = ctx != NULL;
bool flush_ctx = false;
unsigned int ctx_i = 0;
@@ -475,6 +475,7 @@ base32_decode_ctx (struct base32_decode_context *ctx,
flush_ctx = inlen == 0;
}
idx_t outleft = *outlen;
while (true)
{
@@ -512,8 +513,8 @@ base32_decode_ctx (struct base32_decode_context *ctx,
{
char const *in_end = in + inlen;
char const *non_nl;
char const *non_nl;
if (ignore_newlines)
non_nl = get_8 (ctx, &in, in_end, &inlen);
else
+4 -3
View File
@@ -372,13 +372,14 @@ static bool
decode_4 (char const *restrict in, idx_t inlen,
char *restrict *outp, idx_t *outleft)
{
char *out = *outp;
if (inlen < 2)
return false;
if (!isbase64 (in[0]) || !isbase64 (in[1]))
return false;
char *out = *outp;
if (*outleft)
{
*out++ = ((base64_to_int[to_uchar (in[0])] << 2)
@@ -466,7 +467,6 @@ base64_decode_ctx (struct base64_decode_context *ctx,
const char *restrict in, idx_t inlen,
char *restrict out, idx_t *outlen)
{
idx_t outleft = *outlen;
bool ignore_newlines = ctx != NULL;
bool flush_ctx = false;
unsigned int ctx_i = 0;
@@ -477,6 +477,7 @@ base64_decode_ctx (struct base64_decode_context *ctx,
flush_ctx = inlen == 0;
}
idx_t outleft = *outlen;
while (true)
{
@@ -514,8 +515,8 @@ base64_decode_ctx (struct base64_decode_context *ctx,
{
char const *in_end = in + inlen;
char const *non_nl;
char const *non_nl;
if (ignore_newlines)
non_nl = get_4 (ctx, &in, in_end, &inlen);
else
+2 -4
View File
@@ -29,11 +29,10 @@ char *
last_component (char const *name)
{
char const *base = name + FILE_SYSTEM_PREFIX_LEN (name);
bool last_was_slash = false;
while (ISSLASH (*base))
base++;
bool last_was_slash = false;
for (char const *p = base; *p; p++)
{
if (ISSLASH (*p))
@@ -52,8 +51,6 @@ size_t
base_len (char const *name)
{
size_t len;
size_t prefix_len = FILE_SYSTEM_PREFIX_LEN (name);
for (len = strlen (name); 1 < len && ISSLASH (name[len - 1]); len--)
continue;
@@ -61,6 +58,7 @@ base_len (char const *name)
&& ISSLASH (name[0]) && ISSLASH (name[1]) && ! name[2])
return 2;
size_t prefix_len = FILE_SYSTEM_PREFIX_LEN (name);
if (FILE_SYSTEM_DRIVE_PREFIX_CAN_BE_RELATIVE && prefix_len
&& len == prefix_len && ISSLASH (name[prefix_len]))
return prefix_len + 1;
+4 -3
View File
@@ -367,12 +367,13 @@ bitset_count_ (bitset src)
bool
bitset_copy_ (bitset dst, bitset src)
{
bitset_bindex i;
bitset_iterator iter;
/* Convert bitset types. We assume that the DST bitset
is large enough to hold the SRC bitset. */
bitset_zero (dst);
bitset_bindex i;
bitset_iterator iter;
BITSET_FOR_EACH (iter, src, i, 0)
bitset_set (dst, i);
+22 -19
View File
@@ -227,11 +227,11 @@ lbitset_prune (bitset bset, lbitset_elt *elt)
bset->b.csize = 0;
}
lbitset_elt *next;
for (; elt; elt = next)
for (; elt;)
{
next = elt->next;
lbitset_elt *next = elt->next;
lbitset_elt_free (elt);
elt = next;
}
}
@@ -378,12 +378,12 @@ lbitset_elt_find (bitset bset, bitset_windex windex,
static inline void
lbitset_weed (bitset bset)
{
lbitset_elt *next;
for (lbitset_elt *elt = LBITSET_HEAD (bset); elt; elt = next)
for (lbitset_elt *elt = LBITSET_HEAD (bset); elt;)
{
next = elt->next;
lbitset_elt *next = elt->next;
if (lbitset_elt_zero_p (elt))
lbitset_elt_unlink (bset, elt);
elt = next;
}
}
@@ -724,19 +724,22 @@ lbitset_list (bitset bset, bitset_bindex *list,
/* The coast is clear, plant boot! */
#if LBITSET_ELT_WORDS == 2
bitset_word word = srcp[0];
if (word)
BITSET_FOR_EACH_BIT (pos, word)
list[count++] = bitno + pos;
windex++;
bitno = windex * BITSET_WORD_BITS;
word = srcp[1];
if (word)
BITSET_FOR_EACH_BIT (pos, word)
list[count++] = bitno + pos;
windex++;
bitno = windex * BITSET_WORD_BITS;
{
bitset_word word = srcp[0];
if (word)
BITSET_FOR_EACH_BIT (pos, word)
list[count++] = bitno + pos;
windex++;
bitno = windex * BITSET_WORD_BITS;
}
{
bitset_word word = srcp[1];
if (word)
BITSET_FOR_EACH_BIT (pos, word)
list[count++] = bitno + pos;
windex++;
bitno = windex * BITSET_WORD_BITS;
}
#else
for (int i = 0; i < LBITSET_ELT_WORDS; i++)
{
+16 -13
View File
@@ -658,19 +658,22 @@ tbitset_list (bitset bset, bitset_bindex *list,
/* The coast is clear, plant boot! */
#if TBITSET_ELT_WORDS == 2
bitset_word word = srcp[0];
if (word)
BITSET_FOR_EACH_BIT (pos, word)
list[count++] = bitno + pos;
windex++;
bitno = windex * BITSET_WORD_BITS;
word = srcp[1];
if (word)
BITSET_FOR_EACH_BIT (pos, word)
list[count++] = bitno + pos;
windex++;
bitno = windex * BITSET_WORD_BITS;
{
bitset_word word = srcp[0];
if (word)
BITSET_FOR_EACH_BIT (pos, word)
list[count++] = bitno + pos;
windex++;
bitno = windex * BITSET_WORD_BITS;
}
{
bitset_word word = srcp[1];
if (word)
BITSET_FOR_EACH_BIT (pos, word)
list[count++] = bitno + pos;
windex++;
bitno = windex * BITSET_WORD_BITS;
}
#else
for (int i = 0; i < TBITSET_ELT_WORDS; i++, windex++)
{
+5 -2
View File
@@ -395,13 +395,15 @@ get_windows_boot_time_fallback (struct timespec *p_boot_time)
if (GetTickCount64Func != NULL)
{
ULONGLONG uptime_ms = GetTickCount64Func ();
struct timespec uptime;
struct timespec result;
struct timeval tv;
if (gettimeofday (&tv, NULL) >= 0)
{
struct timespec uptime;
uptime.tv_sec = uptime_ms / 1000;
uptime.tv_nsec = (uptime_ms % 1000) * 1000000;
struct timespec result;
result.tv_sec = tv.tv_sec;
result.tv_nsec = tv.tv_usec * 1000;
if (result.tv_nsec < uptime.tv_nsec)
@@ -411,6 +413,7 @@ get_windows_boot_time_fallback (struct timespec *p_boot_time)
}
result.tv_sec -= uptime.tv_sec;
result.tv_nsec -= uptime.tv_nsec;
*p_boot_time = result;
return 0;
}
+2 -3
View File
@@ -42,11 +42,10 @@ btoc32 (int c)
if (c != EOF)
{
mbstate_t state;
char s[1];
char32_t wc;
mbszero (&state);
char s[1];
s[0] = (unsigned char) c;
char32_t wc;
if (mbrtoc32 (&wc, s, 1, &state) <= 1)
return wc;
}
+2 -3
View File
@@ -26,10 +26,9 @@ int
c_asprintf (char **resultp, const char *format, ...)
{
va_list args;
int result;
va_start (args, format);
result = c_vasprintf (resultp, format, args);
int result = c_vasprintf (resultp, format, args);
va_end (args);
return result;
}
+2 -3
View File
@@ -25,10 +25,9 @@ ptrdiff_t
c_aszprintf (char **resultp, const char *format, ...)
{
va_list args;
ptrdiff_t result;
va_start (args, format);
result = c_vaszprintf (resultp, format, args);
ptrdiff_t result = c_vaszprintf (resultp, format, args);
va_end (args);
return result;
}
+3 -3
View File
@@ -30,10 +30,10 @@ int
c_snprintf (char *str, size_t size, const char *format, ...)
{
va_list args;
ptrdiff_t ret;
va_start (args, format);
ret = c_vsnzprintf (str, size, format, args);
ptrdiff_t ret = c_vsnzprintf (str, size, format, args);
va_end (args);
#if PTRDIFF_MAX > INT_MAX
+5 -6
View File
@@ -31,14 +31,13 @@
ptrdiff_t
c_snzprintf (char *str, size_t size, const char *format, ...)
{
char *output;
size_t len;
size_t lenbuf = size;
va_list args;
va_start (args, format);
output = c_vasnprintf (str, &lenbuf, format, args);
len = lenbuf;
size_t lenbuf = size;
char *output = c_vasnprintf (str, &lenbuf, format, args);
size_t len = lenbuf;
va_end (args);
if (!output)
+13 -18
View File
@@ -28,29 +28,24 @@ c_strcasecmp (const char *s1, const char *s2)
{
register const unsigned char *p1 = (const unsigned char *) s1;
register const unsigned char *p2 = (const unsigned char *) s2;
unsigned char c1, c2;
if (p1 == p2)
return 0;
do
for (;; p1++, p2++)
{
c1 = c_tolower (*p1);
c2 = c_tolower (*p2);
unsigned char c1 = c_tolower (*p1);
unsigned char c2 = c_tolower (*p2);
if (c1 == '\0')
break;
++p1;
++p2;
if (c1 == '\0' || c1 != c2)
{
if (UCHAR_MAX <= INT_MAX)
return c1 - c2;
else
/* On machines where 'char' and 'int' are types of the same size,
the difference of two 'unsigned char' values - including the
sign bit - doesn't fit in an 'int'. */
return _GL_CMP (c1, c2);
}
}
while (c1 == c2);
if (UCHAR_MAX <= INT_MAX)
return c1 - c2;
else
/* On machines where 'char' and 'int' are types of the same size, the
difference of two 'unsigned char' values - including the sign bit -
doesn't fit in an 'int'. */
return _GL_CMP (c1, c2);
}
+17 -14
View File
@@ -40,25 +40,28 @@
char *
c_strcasestr (const char *haystack_start, const char *needle_start)
{
const char *haystack = haystack_start;
const char *needle = needle_start;
size_t needle_len; /* Length of NEEDLE. */
size_t haystack_len; /* Known minimum length of HAYSTACK. */
bool ok = true; /* True if NEEDLE is prefix of HAYSTACK. */
/* Determine length of NEEDLE, and in the process, make sure
HAYSTACK is at least as long (no point processing all of a long
NEEDLE if HAYSTACK is too short). */
while (*haystack && *needle)
ok &= (c_tolower ((unsigned char) *haystack++)
== c_tolower ((unsigned char) *needle++));
if (*needle)
return NULL;
if (ok)
return (char *) haystack_start;
needle_len = needle - needle_start;
haystack = haystack_start + 1;
haystack_len = needle_len - 1;
{
const char *haystack = haystack_start;
bool ok = true; /* True if NEEDLE is prefix of HAYSTACK. */
while (*haystack && *needle)
ok &= (c_tolower ((unsigned char) *haystack++)
== c_tolower ((unsigned char) *needle++));
if (*needle)
return NULL;
if (ok)
return (char *) haystack_start;
}
size_t needle_len = /* Length of NEEDLE. */
needle - needle_start;
const char *haystack = haystack_start + 1;
size_t haystack_len = /* Known minimum length of HAYSTACK. */
needle_len - 1;
/* Perform the search. Abstract memory is considered to be an array
of 'unsigned char' values, not an array of 'char' values. See
+13 -18
View File
@@ -28,29 +28,24 @@ c_strncasecmp (const char *s1, const char *s2, size_t n)
{
register const unsigned char *p1 = (const unsigned char *) s1;
register const unsigned char *p2 = (const unsigned char *) s2;
unsigned char c1, c2;
if (p1 == p2 || n == 0)
return 0;
do
for (;; p1++, p2++)
{
c1 = c_tolower (*p1);
c2 = c_tolower (*p2);
unsigned char c1 = c_tolower (*p1);
unsigned char c2 = c_tolower (*p2);
if (--n == 0 || c1 == '\0')
break;
++p1;
++p2;
if (--n == 0 || c1 == '\0' || c1 != c2)
{
if (UCHAR_MAX <= INT_MAX)
return c1 - c2;
else
/* On machines where 'char' and 'int' are types of the same size,
the difference of two 'unsigned char' values - including the
sign bit - doesn't fit in an 'int'. */
return _GL_CMP (c1, c2);
}
}
while (c1 == c2);
if (UCHAR_MAX <= INT_MAX)
return c1 - c2;
else
/* On machines where 'char' and 'int' are types of the same size, the
difference of two 'unsigned char' values - including the sign bit -
doesn't fit in an 'int'. */
return _GL_CMP (c1, c2);
}
+5 -4
View File
@@ -180,8 +180,9 @@ C_STRTOD (char const *nptr, char **endptr)
end = p + 1;
if (p[1] == 'x' || p[1] == 'X')
{
size_t num_hex_digits = 0;
p += 2;
size_t num_hex_digits = 0;
/* Parse a non-empty sequence of hexadecimal digits optionally
containing the decimal point character '.'. */
while (*p != '\0')
@@ -295,11 +296,10 @@ C_STRTOD (char const *nptr, char **endptr)
/* Create a modified floating-point number, in which the character '.'
is replaced with the locale-dependent decimal_point. */
size_t len = end - start;
char stackbuf[1000];
char *buf;
char *buf_malloced = NULL;
char stackbuf[1000];
char *end_in_buf;
if (len < sizeof (stackbuf))
buf = stackbuf;
else
@@ -323,6 +323,7 @@ C_STRTOD (char const *nptr, char **endptr)
buf[decimal_point_p - start] = decimal_point;
buf[len] = '\0';
char *end_in_buf;
r = STRTOD (buf, &end_in_buf);
if (endptr != NULL)
*endptr = (char *) (start + (end_in_buf - buf));
+2 -5
View File
@@ -34,12 +34,9 @@
ptrdiff_t
c_vsnzprintf (char *str, size_t size, const char *format, va_list args)
{
char *output;
size_t len;
size_t lenbuf = size;
output = c_vasnprintf (str, &lenbuf, format, args);
len = lenbuf;
char *output = c_vasnprintf (str, &lenbuf, format, args);
size_t len = lenbuf;
if (!output)
return -1;
+1 -3
View File
@@ -24,10 +24,8 @@ char *
c_xasprintf (const char *format, ...)
{
va_list args;
char *result;
va_start (args, format);
result = c_xvasprintf (format, args);
char *result = c_xvasprintf (format, args);
va_end (args);
return result;
+1 -1
View File
@@ -31,7 +31,7 @@ size_t
c32stombs (char *dest, const char32_t *src, size_t len)
{
mbstate_t state;
mbszero (&state);
return c32srtombs (dest, &src, len, &state);
}
+2 -2
View File
@@ -42,9 +42,9 @@ c32tob (wint_t wc)
if (wc != WEOF)
{
mbstate_t state;
char buf[8];
mbszero (&state);
char buf[8];
if (c32rtomb (buf, wc, &state) == 1)
return (unsigned char) buf[0];
}
+5 -5
View File
@@ -60,13 +60,13 @@ canon_host (const char *host)
char *
canon_host_r (char const *host, int *cherror)
{
char *retval = NULL;
static struct addrinfo hints;
struct addrinfo *res = NULL;
int status;
hints.ai_flags = AI_CANONNAME;
status = getaddrinfo (host, NULL, &hints, &res);
struct addrinfo *res = NULL;
int status = getaddrinfo (host, NULL, &hints, &res);
char *retval = NULL;
if (!status)
{
/* https://lists.gnu.org/r/bug-coreutils/2006-09/msg00300.html
+11 -8
View File
@@ -191,11 +191,6 @@ struct realpath_bufs
static char *
realpath_stk (const char *name, char *resolved, struct realpath_bufs *bufs)
{
char *dest;
char const *start;
char const *end;
int num_links = 0;
if (name == NULL)
{
/* As per Single Unix Specification V2 we must return an error if
@@ -215,13 +210,14 @@ realpath_stk (const char *name, char *resolved, struct realpath_bufs *bufs)
}
char *rname = bufs->rname.data;
bool end_in_extra_buffer = false;
bool failed = true;
/* This is always zero for Posix hosts, but can be 2 for MS-Windows
and MS-DOS X:/foo/bar file names. */
idx_t prefix_len;
char *dest;
char const *start;
if (!IS_ABSOLUTE_FILE_NAME (name))
{
while (!__getcwd (bufs->rname.data, bufs->rname.length))
@@ -254,13 +250,18 @@ realpath_stk (const char *name, char *resolved, struct realpath_bufs *bufs)
start = name + prefix_len;
}
for ( ; *start; start = end)
int num_links = 0;
bool end_in_extra_buffer = false;
bool failed = true;
for (; *start;)
{
/* Skip sequence of multiple file name separators. */
while (ISSLASH (*start))
++start;
/* Find end of component. */
char const *end;
for (end = start; *end && !ISSLASH (*end); ++end)
/* Nothing. */;
@@ -379,6 +380,8 @@ realpath_stk (const char *name, char *resolved, struct realpath_bufs *bufs)
: errno == EINVAL))
goto error;
}
start = end;
}
if (dest > rname + prefix_len + 1 && ISSLASH (dest[-1]))
--dest;
+19 -11
View File
@@ -180,13 +180,6 @@ static char *
canonicalize_filename_mode_stk (const char *name, canonicalize_mode_t can_mode,
struct realpath_bufs *bufs)
{
char *dest;
char const *start;
char const *end;
Hash_table *ht = NULL;
bool logical = (can_mode & CAN_NOLINKS) != 0;
int num_links = 0;
canonicalize_mode_t can_exist = can_mode & CAN_MODE_MASK;
if (multiple_bits_set (can_exist))
{
@@ -207,13 +200,14 @@ canonicalize_filename_mode_stk (const char *name, canonicalize_mode_t can_mode,
}
char *rname = bufs->rname.data;
bool end_in_extra_buffer = false;
bool failed = true;
/* This is always zero for Posix hosts, but can be 2 for MS-Windows
and MS-DOS X:/foo/bar file names. */
idx_t prefix_len;
char *dest;
char const *start;
if (!IS_ABSOLUTE_FILE_NAME (name))
{
while (!getcwd (bufs->rname.data, bufs->rname.length))
@@ -277,13 +271,21 @@ canonicalize_filename_mode_stk (const char *name, canonicalize_mode_t can_mode,
start = name + prefix_len;
}
for ( ; *start; start = end)
bool logical = (can_mode & CAN_NOLINKS) != 0;
int num_links = 0;
Hash_table *ht = NULL;
bool end_in_extra_buffer = false;
bool failed = true;
for (; *start;)
{
/* Skip sequence of multiple file name separators. */
while (ISSLASH (*start))
++start;
/* Find end of component. */
char const *end;
for (end = start; *end && !ISSLASH (*end); ++end)
/* Nothing. */;
@@ -366,7 +368,7 @@ canonicalize_filename_mode_stk (const char *name, canonicalize_mode_t can_mode,
if (seen_triple (&ht, start, &st))
{
if (can_exist == CAN_MISSING)
continue;
goto next_component;
errno = ELOOP;
goto error;
}
@@ -433,6 +435,9 @@ canonicalize_filename_mode_stk (const char *name, canonicalize_mode_t can_mode,
&& !end[strspn (end, SLASHES)])))
goto error;
}
next_component:
start = end;
}
if (dest > rname + prefix_len + 1 && ISSLASH (dest[-1]))
--dest;
@@ -469,9 +474,12 @@ canonicalize_filename_mode (const char *name, canonicalize_mode_t can_mode)
scratch_buffer_init (&bufs.rname);
scratch_buffer_init (&bufs.extra);
scratch_buffer_init (&bufs.link);
char *result = canonicalize_filename_mode_stk (name, can_mode, &bufs);
scratch_buffer_free (&bufs.link);
scratch_buffer_free (&bufs.extra);
scratch_buffer_free (&bufs.rname);
return result;
}
+15 -17
View File
@@ -48,27 +48,25 @@ cbrt (double x)
{
if (isfinite (x) && x != 0.0)
{
double xm, ym, u, t2;
/* Reduce X. XM now is in range 1.0 to 0.5. */
int xe;
double xm = frexp (fabs (x), &xe);
/* Reduce X. XM now is an range 1.0 to 0.5. */
xm = frexp (fabs (x), &xe);
double u = (0.354895765043919860
+ ((1.50819193781584896
+ ((-2.11499494167371287
+ ((2.44693122563534430
+ ((-1.83469277483613086
+ (0.784932344976639262 - 0.145263899385486377 * xm)
* xm)
* xm))
* xm))
* xm))
* xm));
u = (0.354895765043919860
+ ((1.50819193781584896
+ ((-2.11499494167371287
+ ((2.44693122563534430
+ ((-1.83469277483613086
+ (0.784932344976639262 - 0.145263899385486377 * xm)
* xm)
* xm))
* xm))
* xm))
* xm));
double t2 = u * u * u;
t2 = u * u * u;
ym = u * (t2 + 2.0 * xm) / (2.0 * t2 + xm) * factor[2 + xe % 3];
double ym = u * (t2 + 2.0 * xm) / (2.0 * t2 + xm) * factor[2 + xe % 3];
return ldexp (x > 0.0 ? ym : -ym, xe / 3);
}
+6 -8
View File
@@ -48,18 +48,16 @@ cbrtf (float x)
{
if (isfinite (x) && x != 0.0f)
{
float xm, ym, u, t2;
/* Reduce X. XM now is in range 1.0 to 0.5. */
int xe;
float xm = frexpf (fabsf (x), &xe);
/* Reduce X. XM now is an range 1.0 to 0.5. */
xm = frexpf (fabsf (x), &xe);
float u = (0.492659620528969547
+ (0.697570460207922770 - 0.191502161678719066 * xm) * xm);
u = (0.492659620528969547
+ (0.697570460207922770 - 0.191502161678719066 * xm) * xm);
float t2 = u * u * u;
t2 = u * u * u;
ym = u * (t2 + 2.0 * xm) / (2.0 * t2 + xm) * factor[2 + xe % 3];
float ym = u * (t2 + 2.0 * xm) / (2.0 * t2 + xm) * factor[2 + xe % 3];
return ldexpf (x > 0.0 ? ym : -ym, xe / 3);
}
+4 -4
View File
@@ -80,9 +80,7 @@ cbrtl (long double x)
{
if (isfinite (x) && x != 0.0L)
{
int e, rem, sign;
long double z;
int sign;
if (x > 0)
sign = 1;
else
@@ -91,8 +89,9 @@ cbrtl (long double x)
x = -x;
}
z = x;
long double z = x;
/* extract power of 2, leaving mantissa between 0.5 and 1 */
int e;
x = frexpl (x, &e);
/* Approximate cube root of number between .5 and 1,
@@ -104,6 +103,7 @@ cbrtl (long double x)
+ 1.3304961236013647092521e0L) * x + 3.7568280825958912391243e-1L;
/* exponent divided by 3 */
int rem;
if (e >= 0)
{
rem = e;
+7 -12
View File
@@ -115,9 +115,8 @@ chdir_long (char *dir)
{
size_t len = strlen (dir);
char *dir_end = dir + len;
struct cd_buf cdb;
size_t n_leading_slash;
struct cd_buf cdb;
cdb_init (&cdb);
/* If DIR is the empty string, then the chdir above
@@ -126,7 +125,7 @@ chdir_long (char *dir)
assure (PATH_MAX <= len);
/* Count leading slashes. */
n_leading_slash = strspn (dir, "/");
size_t n_leading_slash = strspn (dir, "/");
/* Handle any leading slashes as well as any name that matches
the regular expression, m!^//hostname[/]*! . Handling this
@@ -135,7 +134,6 @@ chdir_long (char *dir)
code in the following loop cleaner. */
if (n_leading_slash == 2)
{
int err;
/* Find next slash.
We already know that dir[2] is neither a slash nor '\0'. */
char *slash = memchr (dir + 3, '/', dir_end - (dir + 3));
@@ -145,7 +143,7 @@ chdir_long (char *dir)
return -1;
}
*slash = '\0';
err = cdb_advance_fd (&cdb, dir);
int err = cdb_advance_fd (&cdb, dir);
*slash = '/';
if (err != 0)
goto Fail;
@@ -163,7 +161,6 @@ chdir_long (char *dir)
while (PATH_MAX <= dir_end - dir)
{
int err;
/* Find a slash that is PATH_MAX or fewer bytes away from dir.
I.e. see if there is a slash that will give us a name of
length PATH_MAX-1 or less. */
@@ -176,7 +173,7 @@ chdir_long (char *dir)
*slash = '\0';
assure (slash - dir < PATH_MAX);
err = cdb_advance_fd (&cdb, dir);
int err = cdb_advance_fd (&cdb, dir);
*slash = '/';
if (err != 0)
goto Fail;
@@ -214,13 +211,11 @@ chdir_long (char *dir)
int
main (int argc, char *argv[])
{
char *line = NULL;
size_t n = 0;
int len;
atexit (close_stdout);
len = getline (&line, &n, stdin);
char *line = NULL;
size_t n = 0;
int len = getline (&line, &n, stdin);
if (len < 0)
{
int saved_errno = errno;
+23 -26
View File
@@ -52,41 +52,38 @@ char *
new_classpath (const char * const *classpaths, unsigned int classpaths_count,
bool use_minimal_classpath)
{
const char *old_classpath;
unsigned int length;
char *result;
char *p;
old_classpath = (use_minimal_classpath ? NULL : getenv (CLASSPATHVAR));
const char *old_classpath = (use_minimal_classpath ? NULL : getenv (CLASSPATHVAR));
if (old_classpath == NULL)
old_classpath = "";
length = 0;
unsigned int length = 0;
for (unsigned int i = 0; i < classpaths_count; i++)
length += strlen (classpaths[i]) + 1;
length += strlen (old_classpath);
if (classpaths_count > 0 && old_classpath[0] == '\0')
length--;
result = XNMALLOC (length + 1, char);
p = result;
for (unsigned int i = 0; i < classpaths_count; i++)
{
memcpy (p, classpaths[i], strlen (classpaths[i]));
p += strlen (classpaths[i]);
*p++ = PATH_SEPARATOR;
}
if (old_classpath[0] != '\0')
{
memcpy (p, old_classpath, strlen (old_classpath));
p += strlen (old_classpath);
}
else
{
if (classpaths_count > 0)
p--;
}
*p = '\0';
char *result = XNMALLOC (length + 1, char);
{
char *p = result;
for (unsigned int i = 0; i < classpaths_count; i++)
{
memcpy (p, classpaths[i], strlen (classpaths[i]));
p += strlen (classpaths[i]);
*p++ = PATH_SEPARATOR;
}
if (old_classpath[0] != '\0')
{
memcpy (p, old_classpath, strlen (old_classpath));
p += strlen (old_classpath);
}
else
{
if (classpaths_count > 0)
p--;
}
*p = '\0';
}
return result;
}
+25 -29
View File
@@ -165,10 +165,8 @@ cleanup_action (_GL_UNUSED int sig)
if (fds != NULL)
{
gl_list_iterator_t iter;
gl_list_iterator_t iter = gl_list_iterator (fds);
const void *element;
iter = gl_list_iterator (fds);
while (gl_list_iterator_next (&iter, &element, NULL))
{
clean_temp_asyncsafe_close ((struct closeable_fd *) element);
@@ -182,10 +180,8 @@ cleanup_action (_GL_UNUSED int sig)
if (files != NULL)
{
gl_list_iterator_t iter;
gl_list_iterator_t iter = gl_list_iterator (files);
const void *element;
iter = gl_list_iterator (files);
while (gl_list_iterator_next (&iter, &element, NULL))
{
const char *file = (const char *) element;
@@ -201,26 +197,28 @@ cleanup_action (_GL_UNUSED int sig)
if (dir != NULL)
{
gl_list_iterator_t iter;
const void *element;
/* First cleanup the files in the subdirectories. */
iter = gl_list_iterator (dir->files);
while (gl_list_iterator_next (&iter, &element, NULL))
{
const char *file = (const char *) element;
unlink (file);
}
gl_list_iterator_free (&iter);
/* Then cleanup the subdirectories. */
iter = gl_list_iterator (dir->subdirs);
while (gl_list_iterator_next (&iter, &element, NULL))
{
const char *subdir = (const char *) element;
rmdir (subdir);
}
gl_list_iterator_free (&iter);
{
/* First cleanup the files in the subdirectories. */
gl_list_iterator_t iter = gl_list_iterator (dir->files);
const void *element;
while (gl_list_iterator_next (&iter, &element, NULL))
{
const char *file = (const char *) element;
unlink (file);
}
gl_list_iterator_free (&iter);
}
{
/* Then cleanup the subdirectories. */
gl_list_iterator_t iter = gl_list_iterator (dir->subdirs);
const void *element;
while (gl_list_iterator_next (&iter, &element, NULL))
{
const char *subdir = (const char *) element;
rmdir (subdir);
}
gl_list_iterator_free (&iter);
}
/* Then cleanup the temporary directory itself. */
rmdir (dir->dirname);
@@ -363,9 +361,7 @@ unregister_temporary_file (const char *absolute_file_name)
int
cleanup_temporary_file (const char *absolute_file_name, bool cleanup_verbose)
{
int err;
err = clean_temp_unlink (absolute_file_name, cleanup_verbose);
int err = clean_temp_unlink (absolute_file_name, cleanup_verbose);
unregister_temporary_file (absolute_file_name);
return err;
+105 -112
View File
@@ -150,13 +150,9 @@ create_temp_dir (const char *prefix, const char *parentdir,
if (mt) gl_lock_lock (dir_cleanup_list_lock);
struct tempdir * volatile *tmpdirp = NULL;
struct tempdir *tmpdir;
char *xtemplate;
char *tmpdirname;
/* See whether it can take the slot of an earlier temporary directory
already cleaned up. */
struct tempdir * volatile *tmpdirp = NULL;
for (size_t i = 0; i < dir_cleanup_list.tempdir_count; i++)
if (dir_cleanup_list.tempdir_list[i] == NULL)
{
@@ -214,7 +210,7 @@ create_temp_dir (const char *prefix, const char *parentdir,
}
/* Initialize a 'struct tempdir'. */
tmpdir = XMALLOC (struct tempdir);
struct tempdir *tmpdir = XMALLOC (struct tempdir);
tmpdir->dirname = NULL;
tmpdir->cleanup_verbose = cleanup_verbose;
tmpdir->subdirs =
@@ -227,7 +223,7 @@ create_temp_dir (const char *prefix, const char *parentdir,
NULL, false);
/* Create the temporary directory. */
xtemplate = (char *) xmalloca (PATH_MAX);
char *xtemplate = (char *) xmalloca (PATH_MAX);
if (path_search (xtemplate, PATH_MAX, parentdir, prefix, parentdir == NULL))
{
error (0, errno,
@@ -235,7 +231,7 @@ create_temp_dir (const char *prefix, const char *parentdir,
goto quit;
}
block_fatal_signals ();
tmpdirname = mkdtemp (xtemplate);
char *tmpdirname = mkdtemp (xtemplate);
int saved_errno = errno;
if (tmpdirname != NULL)
{
@@ -297,9 +293,8 @@ unregister_temp_file (struct temp_dir *dir,
if (mt) gl_lock_lock (dir_cleanup_list_lock);
gl_list_t list = tmpdir->files;
gl_list_node_t node;
node = gl_list_search (list, absolute_file_name);
gl_list_node_t node = gl_list_search (list, absolute_file_name);
if (node != NULL)
{
char *old_string = (char *) gl_list_node_value (list, node);
@@ -344,9 +339,8 @@ unregister_temp_subdir (struct temp_dir *dir,
if (mt) gl_lock_lock (dir_cleanup_list_lock);
gl_list_t list = tmpdir->subdirs;
gl_list_node_t node;
node = gl_list_search (list, absolute_dir_name);
gl_list_node_t node = gl_list_search (list, absolute_dir_name);
if (node != NULL)
{
char *old_string = (char *) gl_list_node_value (list, node);
@@ -379,9 +373,7 @@ int
cleanup_temp_file (struct temp_dir *dir,
const char *absolute_file_name)
{
int err;
err = clean_temp_unlink (absolute_file_name, dir->cleanup_verbose);
int err = clean_temp_unlink (absolute_file_name, dir->cleanup_verbose);
unregister_temp_file (dir, absolute_file_name);
return err;
@@ -393,9 +385,7 @@ int
cleanup_temp_subdir (struct temp_dir *dir,
const char *absolute_dir_name)
{
int err;
err = do_rmdir (absolute_dir_name, dir->cleanup_verbose);
int err = do_rmdir (absolute_dir_name, dir->cleanup_verbose);
unregister_temp_subdir (dir, absolute_dir_name);
return err;
@@ -409,38 +399,42 @@ cleanup_temp_dir_contents (struct temp_dir *dir)
{
struct tempdir *tmpdir = (struct tempdir *)dir;
int err = 0;
gl_list_t list;
gl_list_iterator_t iter;
const void *element;
gl_list_node_t node;
/* First cleanup the files in the subdirectories. */
list = tmpdir->files;
iter = gl_list_iterator (list);
while (gl_list_iterator_next (&iter, &element, &node))
{
char *file = (char *) element;
{
gl_list_t list = tmpdir->files;
gl_list_iterator_t iter = gl_list_iterator (list);
const void *element;
gl_list_node_t node;
while (gl_list_iterator_next (&iter, &element, &node))
{
char *file = (char *) element;
err |= clean_temp_unlink (file, dir->cleanup_verbose);
gl_list_remove_node (list, node);
/* Now only we can free file. */
free (file);
}
gl_list_iterator_free (&iter);
err |= clean_temp_unlink (file, dir->cleanup_verbose);
gl_list_remove_node (list, node);
/* Now only we can free file. */
free (file);
}
gl_list_iterator_free (&iter);
}
/* Then cleanup the subdirectories. */
list = tmpdir->subdirs;
iter = gl_list_iterator (list);
while (gl_list_iterator_next (&iter, &element, &node))
{
char *subdir = (char *) element;
{
gl_list_t list = tmpdir->subdirs;
gl_list_iterator_t iter = gl_list_iterator (list);
const void *element;
gl_list_node_t node;
while (gl_list_iterator_next (&iter, &element, &node))
{
char *subdir = (char *) element;
err |= do_rmdir (subdir, dir->cleanup_verbose);
gl_list_remove_node (list, node);
/* Now only we can free subdir. */
free (subdir);
}
gl_list_iterator_free (&iter);
err |= do_rmdir (subdir, dir->cleanup_verbose);
gl_list_remove_node (list, node);
/* Now only we can free subdir. */
free (subdir);
}
gl_list_iterator_free (&iter);
}
return err;
}
@@ -553,10 +547,8 @@ register_fd (int fd)
int
open_temp (const char *file_name, int flags, mode_t mode, bool delete_on_close)
{
int fd;
int saved_errno;
block_fatal_signals ();
int fd;
/* Note: 'open' here is actually open() or open_safer(). */
#if defined _WIN32 && ! defined __CYGWIN__
/* Use _O_TEMPORARY when possible, to increase the chances that the
@@ -566,7 +558,7 @@ open_temp (const char *file_name, int flags, mode_t mode, bool delete_on_close)
else
#endif
fd = open (file_name, flags, mode);
saved_errno = errno;
int saved_errno = errno;
if (fd >= 0)
register_fd (fd);
unblock_fatal_signals ();
@@ -582,10 +574,9 @@ open_temp (const char *file_name, int flags, mode_t mode, bool delete_on_close)
FILE *
fopen_temp (const char *file_name, const char *mode, bool delete_on_close)
{
block_fatal_signals ();
FILE *fp;
int saved_errno;
block_fatal_signals ();
/* Note: 'fopen' here is actually fopen() or fopen_safer(). */
#if defined _WIN32 && ! defined __CYGWIN__
/* Use _O_TEMPORARY when possible, to increase the chances that the
@@ -687,9 +678,6 @@ close_temp (int fd)
clean_temp_init_asyncsafe_close ();
int result = 0;
int saved_errno = 0;
bool mt = gl_multithreaded ();
if (mt) gl_lock_lock (descriptors_lock);
@@ -700,40 +688,44 @@ close_temp (int fd)
abort ();
/* Search through the list, and clean it up on the fly. */
int result = 0;
int saved_errno = 0;
bool found = false;
gl_list_iterator_t iter = gl_list_iterator (list);
const void *elt;
gl_list_node_t node;
if (gl_list_iterator_next (&iter, &elt, &node))
for (;;)
{
struct closeable_fd *element = (struct closeable_fd *) elt;
{
gl_list_iterator_t iter = gl_list_iterator (list);
const void *elt;
gl_list_node_t node;
if (gl_list_iterator_next (&iter, &elt, &node))
for (;;)
{
struct closeable_fd *element = (struct closeable_fd *) elt;
/* Close the file descriptor, avoiding races with the signal
handler. */
if (element->fd == fd)
{
found = true;
result = clean_temp_asyncsafe_close (element);
saved_errno = errno;
}
/* Close the file descriptor, avoiding races with the signal
handler. */
if (element->fd == fd)
{
found = true;
result = clean_temp_asyncsafe_close (element);
saved_errno = errno;
}
bool free_this_node = element->done;
struct closeable_fd *element_to_free = element;
gl_list_node_t node_to_free = node;
bool free_this_node = element->done;
struct closeable_fd *element_to_free = element;
gl_list_node_t node_to_free = node;
bool have_next = gl_list_iterator_next (&iter, &elt, &node);
bool have_next = gl_list_iterator_next (&iter, &elt, &node);
if (free_this_node)
{
free (element_to_free);
gl_list_remove_node (list, node_to_free);
}
if (free_this_node)
{
free (element_to_free);
gl_list_remove_node (list, node_to_free);
}
if (!have_next)
break;
}
gl_list_iterator_free (&iter);
if (!have_next)
break;
}
gl_list_iterator_free (&iter);
}
if (!found)
/* descriptors should already contain fd. */
abort ();
@@ -749,9 +741,6 @@ fclose_variant_temp (FILE *fp, int (*fclose_variant) (FILE *))
{
int fd = fileno (fp);
int result = 0;
int saved_errno = 0;
bool mt = gl_multithreaded ();
if (mt) gl_lock_lock (descriptors_lock);
@@ -762,40 +751,44 @@ fclose_variant_temp (FILE *fp, int (*fclose_variant) (FILE *))
abort ();
/* Search through the list, and clean it up on the fly. */
int result = 0;
int saved_errno = 0;
bool found = false;
gl_list_iterator_t iter = gl_list_iterator (list);
const void *elt;
gl_list_node_t node;
if (gl_list_iterator_next (&iter, &elt, &node))
for (;;)
{
struct closeable_fd *element = (struct closeable_fd *) elt;
{
gl_list_iterator_t iter = gl_list_iterator (list);
const void *elt;
gl_list_node_t node;
if (gl_list_iterator_next (&iter, &elt, &node))
for (;;)
{
struct closeable_fd *element = (struct closeable_fd *) elt;
/* Close the file descriptor and the stream, avoiding races with the
signal handler. */
if (element->fd == fd)
{
found = true;
result = asyncsafe_fclose_variant (element, fp, fclose_variant);
saved_errno = errno;
}
/* Close the file descriptor and the stream, avoiding races with the
signal handler. */
if (element->fd == fd)
{
found = true;
result = asyncsafe_fclose_variant (element, fp, fclose_variant);
saved_errno = errno;
}
bool free_this_node = element->done;
struct closeable_fd *element_to_free = element;
gl_list_node_t node_to_free = node;
bool free_this_node = element->done;
struct closeable_fd *element_to_free = element;
gl_list_node_t node_to_free = node;
bool have_next = gl_list_iterator_next (&iter, &elt, &node);
bool have_next = gl_list_iterator_next (&iter, &elt, &node);
if (free_this_node)
{
free (element_to_free);
gl_list_remove_node (list, node_to_free);
}
if (free_this_node)
{
free (element_to_free);
gl_list_remove_node (list, node_to_free);
}
if (!have_next)
break;
}
gl_list_iterator_free (&iter);
if (!have_next)
break;
}
gl_list_iterator_free (&iter);
}
if (!found)
/* descriptors should have contained fd. */
abort ();
+15 -15
View File
@@ -48,31 +48,28 @@ copy_file_internal (const char *src_filename, const char *dest_filename,
bool preserve)
{
int err = 0;
int src_fd;
struct stat statbuf;
int mode;
int dest_fd;
src_fd = open (src_filename, O_RDONLY | O_BINARY | O_CLOEXEC);
int src_fd = open (src_filename, O_RDONLY | O_BINARY | O_CLOEXEC);
if (src_fd < 0)
return GL_COPY_ERR_OPEN_READ;
struct stat statbuf;
if (fstat (src_fd, &statbuf) < 0)
{
err = GL_COPY_ERR_OPEN_READ;
goto error_src;
}
mode = statbuf.st_mode & 07777;
int mode = statbuf.st_mode & 07777;
off_t inbytes = S_ISREG (statbuf.st_mode) ? statbuf.st_size : -1;
bool empty_regular_file = inbytes == 0;
dest_fd = open (dest_filename,
O_WRONLY | O_CREAT | O_TRUNC | O_BINARY | O_CLOEXEC,
/* If preserve is true, we must assume that the file may
have confidential contents. Therefore open it with mode
0600 and assign the permissions at the end.
If preserve is false, open it with mode 0666 & ~umask. */
preserve ? 0600 : 0666);
int dest_fd = open (dest_filename,
O_WRONLY | O_CREAT | O_TRUNC | O_BINARY | O_CLOEXEC,
/* If preserve is true, we must assume that the file may
have confidential contents. Therefore open it with
mode 0600 and assign the permissions at the end.
If preserve is false, open it with mode 0666 & ~umask. */
preserve ? 0600 : 0666);
if (dest_fd < 0)
{
err = GL_COPY_ERR_OPEN_BACKUP_WRITE;
@@ -102,7 +99,10 @@ copy_file_internal (const char *src_filename, const char *dest_filename,
int bufsize = IO_SIZE;
char *buf = malloc (bufsize);
if (!buf)
buf = smallbuf, bufsize = sizeof smallbuf;
{
buf = smallbuf;
bufsize = sizeof smallbuf;
}
while (true)
{
@@ -142,9 +142,9 @@ copy_file_internal (const char *src_filename, const char *dest_filename,
/* Preserve the access and modification times. */
{
struct timespec ts[2];
ts[0] = get_stat_atime (&statbuf);
ts[1] = get_stat_mtime (&statbuf);
utimens (dest_filename, ts);
}
+6 -5
View File
@@ -83,9 +83,6 @@ cosl (long double x)
long double
cosl (long double x)
{
long double y[2],z=0.0L;
int n;
/* cosl(NaN) is NaN */
if (isnanl (x))
return x;
@@ -93,7 +90,10 @@ cosl (long double x)
/* |x| ~< pi/4 */
if (x >= -0.7853981633974483096156608458198757210492
&& x <= 0.7853981633974483096156608458198757210492)
return kernel_cosl(x, z);
{
long double z = 0.0L;
return kernel_cosl(x, z);
}
/* cosl(Inf) is NaN, cosl(0) is 1 */
else if (x + x == x && x != 0.0)
@@ -102,7 +102,8 @@ cosl (long double x)
/* argument reduction needed */
else
{
n = ieee754_rem_pio2l (x, y);
long double y[2];
int n = ieee754_rem_pio2l (x, y);
switch (n & 3)
{
case 0:
+1 -3
View File
@@ -43,11 +43,9 @@ static unsigned long crc_table[256];
static void
make_crc_table (int bits)
{
unsigned long c;
for (int n = 0; n < 256; n++)
{
c = (unsigned long) n;
unsigned long c = (unsigned long) n;
for (int k = 0; k < bits; k++)
{
if (c & 1)
+98 -86
View File
@@ -32,23 +32,6 @@ __attribute__ ((__target__ ("pclmul,avx")))
uint32_t
crc32_update_no_xor_pclmul (uint32_t crc, const void *buf, size_t len)
{
const __m128i_u *data = buf;
__m128i *datarw;
size_t bytes_remaining = len;
__m128i in256[4] = { 0 };
__m128i xor_crc;
__m128i in1 = _mm_setzero_si128 ();
__m128i in2 = _mm_setzero_si128 ();
__m128i in3 = _mm_setzero_si128 ();
__m128i in4 = _mm_setzero_si128 ();
__m128i in5 = _mm_setzero_si128 ();
__m128i in6 = _mm_setzero_si128 ();
__m128i in7 = _mm_setzero_si128 ();
__m128i in8 = _mm_setzero_si128 ();
__m128i final_buf[12] = { 0 };
__m128i fold_high;
__m128i fold_low;
/* These constants are calculated as T-1 mod P
0x8F352D95 = (544 - 1) mod P etc
This method is described in Fast CRC Computation for Generic Polynomials
@@ -60,45 +43,60 @@ crc32_update_no_xor_pclmul (uint32_t crc, const void *buf, size_t len)
P(x) is the generator polynomial for this CRC32 implementation */
__m128i mu_poly = _mm_set_epi64x (0x1DB710641, 0x1F7011641);
const __m128i_u *data = buf;
size_t bytes_remaining = len;
__m128i final_buf[12] = { 0 };
__m128i *datarw;
if (bytes_remaining >= 128)
{
/* Here we fold 4x 128bit words forward by 512 bits */
/* First load up our initial state */
in1 = _mm_loadu_si128 (data);
in2 = _mm_loadu_si128 (data + 1);
in3 = _mm_loadu_si128 (data + 2);
in4 = _mm_loadu_si128 (data + 3);
__m128i in1 = _mm_loadu_si128 (data);
__m128i in2 = _mm_loadu_si128 (data + 1);
__m128i in3 = _mm_loadu_si128 (data + 2);
__m128i in4 = _mm_loadu_si128 (data + 3);
/* Initialise with incoming CRC */
xor_crc = _mm_set_epi32 (0, 0, 0, crc);
in1 = _mm_xor_si128 (in1, xor_crc);
{
__m128i xor_crc = _mm_set_epi32 (0, 0, 0, crc);
in1 = _mm_xor_si128 (in1, xor_crc);
}
while (bytes_remaining >= 128)
{
/* Load up second set of 512 bits */
in5 = _mm_loadu_si128 (data + 4);
in6 = _mm_loadu_si128 (data + 5);
in7 = _mm_loadu_si128 (data + 6);
in8 = _mm_loadu_si128 (data + 7);
__m128i in5 = _mm_loadu_si128 (data + 4);
__m128i in6 = _mm_loadu_si128 (data + 5);
__m128i in7 = _mm_loadu_si128 (data + 6);
__m128i in8 = _mm_loadu_si128 (data + 7);
/* We shift the high QWORD forward 544 bits and the
low QWORD 480 bits */
fold_high = _mm_clmulepi64_si128 (in1, shift544_shift480, 0x11);
fold_low = _mm_clmulepi64_si128 (in1, shift544_shift480, 0x00);
in1 = _mm_xor_si128 (in5, fold_high);
in1 = _mm_xor_si128 (in1, fold_low);
fold_high = _mm_clmulepi64_si128 (in2, shift544_shift480, 0x11);
fold_low = _mm_clmulepi64_si128 (in2, shift544_shift480, 0x00);
in2 = _mm_xor_si128 (in6, fold_high);
in2 = _mm_xor_si128 (in2, fold_low);
fold_high = _mm_clmulepi64_si128 (in3, shift544_shift480, 0x11);
fold_low = _mm_clmulepi64_si128 (in3, shift544_shift480, 0x00);
in3 = _mm_xor_si128 (in7, fold_high);
in3 = _mm_xor_si128 (in3, fold_low);
fold_high = _mm_clmulepi64_si128 (in4, shift544_shift480, 0x11);
fold_low = _mm_clmulepi64_si128 (in4, shift544_shift480, 0x00);
in4 = _mm_xor_si128 (in8, fold_high);
in4 = _mm_xor_si128 (in4, fold_low);
{
__m128i fold_high = _mm_clmulepi64_si128 (in1, shift544_shift480, 0x11);
__m128i fold_low = _mm_clmulepi64_si128 (in1, shift544_shift480, 0x00);
in1 = _mm_xor_si128 (in5, fold_high);
in1 = _mm_xor_si128 (in1, fold_low);
}
{
__m128i fold_high = _mm_clmulepi64_si128 (in2, shift544_shift480, 0x11);
__m128i fold_low = _mm_clmulepi64_si128 (in2, shift544_shift480, 0x00);
in2 = _mm_xor_si128 (in6, fold_high);
in2 = _mm_xor_si128 (in2, fold_low);
}
{
__m128i fold_high = _mm_clmulepi64_si128 (in3, shift544_shift480, 0x11);
__m128i fold_low = _mm_clmulepi64_si128 (in3, shift544_shift480, 0x00);
in3 = _mm_xor_si128 (in7, fold_high);
in3 = _mm_xor_si128 (in3, fold_low);
}
{
__m128i fold_high = _mm_clmulepi64_si128 (in4, shift544_shift480, 0x11);
__m128i fold_low = _mm_clmulepi64_si128 (in4, shift544_shift480, 0x00);
in4 = _mm_xor_si128 (in8, fold_high);
in4 = _mm_xor_si128 (in4, fold_low);
}
bytes_remaining -= 64;
data += 4;
@@ -118,9 +116,11 @@ crc32_update_no_xor_pclmul (uint32_t crc, const void *buf, size_t len)
/* Move everything to final_buf because it is RW */
/* XOR in previous CRC value */
memcpy (final_buf, data, bytes_remaining);
in1 = _mm_loadu_si128 (final_buf);
xor_crc = _mm_set_epi32 (0, 0, 0, crc);
in1 = _mm_xor_si128 (in1, xor_crc);
__m128i in1 = _mm_loadu_si128 (final_buf);
{
__m128i xor_crc = _mm_set_epi32 (0, 0, 0, crc);
in1 = _mm_xor_si128 (in1, xor_crc);
}
_mm_storeu_si128 (final_buf, in1);
datarw = final_buf;
}
@@ -128,13 +128,13 @@ crc32_update_no_xor_pclmul (uint32_t crc, const void *buf, size_t len)
while (bytes_remaining >= 32)
{
/* Do 128-bit folds as above */
in1 = _mm_loadu_si128 (datarw);
in2 = _mm_loadu_si128 (datarw + 1);
__m128i in1 = _mm_loadu_si128 (datarw);
__m128i in2 = _mm_loadu_si128 (datarw + 1);
/* We shift the high QWORD forward 160 bits and the
low QWORD 96 bits */
fold_high = _mm_clmulepi64_si128 (in1, shift160_shift96, 0x11);
fold_low = _mm_clmulepi64_si128 (in1, shift160_shift96, 0x00);
__m128i fold_high = _mm_clmulepi64_si128 (in1, shift160_shift96, 0x11);
__m128i fold_low = _mm_clmulepi64_si128 (in1, shift160_shift96, 0x00);
in2 = _mm_xor_si128 (in2, fold_high);
in2 = _mm_xor_si128 (in2, fold_low);
@@ -149,6 +149,8 @@ crc32_update_no_xor_pclmul (uint32_t crc, const void *buf, size_t len)
which means with little endian we're shifting the number higher
we'll also use this step to pick the <16 byte case */
__m128i in1;
if (bytes_remaining != 16)
{
/* Pad remainder and fold 128-bits
@@ -156,16 +158,21 @@ crc32_update_no_xor_pclmul (uint32_t crc, const void *buf, size_t len)
This is inefficient so we only actually want to hit this on the actual end of data
If we're reading a multiple of 32 bytes in the loop then this will never get hit */
__m128i in2;
/* Read in at an offset so we get the shift for free */
memcpy (((char *) in256) + (32 - bytes_remaining), datarw,
bytes_remaining);
in1 = _mm_loadu_si128 (in256);
in2 = _mm_loadu_si128 (in256 + 1);
{
__m128i in256[4] = { 0 };
memcpy (((char *) in256) + (32 - bytes_remaining), datarw,
bytes_remaining);
in1 = _mm_loadu_si128 (in256);
in2 = _mm_loadu_si128 (in256 + 1);
}
/* Now we fold in1 onto in2 */
shift160_shift96 = _mm_set_epi64x (0x0ccaa009e, 0x1751997d0);
fold_high = _mm_clmulepi64_si128 (in1, shift160_shift96, 0x11);
fold_low = _mm_clmulepi64_si128 (in1, shift160_shift96, 0x00);
__m128i fold_high = _mm_clmulepi64_si128 (in1, shift160_shift96, 0x11);
__m128i fold_low = _mm_clmulepi64_si128 (in1, shift160_shift96, 0x00);
in2 = _mm_xor_si128 (in2, fold_high);
in1 = _mm_xor_si128 (in2, fold_low);
}
@@ -174,36 +181,41 @@ crc32_update_no_xor_pclmul (uint32_t crc, const void *buf, size_t len)
/* We now have 16 bytes and fold as normal */
in2 =
_mm_and_si128 (_mm_srli_si128 (in1, 8), _mm_set_epi64x (0, 0xffffffff));
in3 =
_mm_and_si128 (_mm_srli_si128 (in1, 12), _mm_set_epi64x (0, 0xffffffff));
in1 = _mm_and_si128 (in1, _mm_set_epi64x (0, 0xffffffffffffffff));
/* Multiply first 64 bits against shift96 */
in1 = _mm_clmulepi64_si128 (shift96_shift64, in1, 0x00);
/* First 32 bits go on in2 */
in2 =
_mm_xor_si128 (in2, _mm_and_si128 (in1, _mm_set_epi64x (0, 0xffffffff)));
/* Next 64 bits go on in3 */
in3 = _mm_xor_si128 (in3, _mm_srli_si128 (in1, 4));
/* Then shift 64 bits from here */
in1 = _mm_clmulepi64_si128 (shift96_shift64, in2, 0x01);
in1 = _mm_xor_si128 (in1, in3);
{
__m128i in2;
__m128i in3;
/* This is the Barrett reduction */
/* Take the bottom 32 bits */
in2 = _mm_and_si128 (in1, _mm_set_epi64x (0, 0xffffffff));
/* Multiply by mu */
in2 = _mm_clmulepi64_si128 (mu_poly, in2, 0x00);
/* Take the bottom 32 bits of the result */
in2 = _mm_and_si128 (in2, _mm_set_epi64x (0, 0xffffffff));
/* Multiply by P(x) */
in2 = _mm_clmulepi64_si128 (mu_poly, in2, 0x01);
/* XOR against input */
in1 = _mm_xor_si128 (in1, in2);
/* Take bits 32-63 as the CRC */
in1 = _mm_srli_si128 (in1, 4);
crc = _mm_cvtsi128_si32 (in1);
in2 =
_mm_and_si128 (_mm_srli_si128 (in1, 8), _mm_set_epi64x (0, 0xffffffff));
in3 =
_mm_and_si128 (_mm_srli_si128 (in1, 12), _mm_set_epi64x (0, 0xffffffff));
in1 = _mm_and_si128 (in1, _mm_set_epi64x (0, 0xffffffffffffffff));
/* Multiply first 64 bits against shift96 */
in1 = _mm_clmulepi64_si128 (shift96_shift64, in1, 0x00);
/* First 32 bits go on in2 */
in2 =
_mm_xor_si128 (in2, _mm_and_si128 (in1, _mm_set_epi64x (0, 0xffffffff)));
/* Next 64 bits go on in3 */
in3 = _mm_xor_si128 (in3, _mm_srli_si128 (in1, 4));
/* Then shift 64 bits from here */
in1 = _mm_clmulepi64_si128 (shift96_shift64, in2, 0x01);
in1 = _mm_xor_si128 (in1, in3);
return crc;
/* This is the Barrett reduction */
/* Take the bottom 32 bits */
in2 = _mm_and_si128 (in1, _mm_set_epi64x (0, 0xffffffff));
/* Multiply by mu */
in2 = _mm_clmulepi64_si128 (mu_poly, in2, 0x00);
/* Take the bottom 32 bits of the result */
in2 = _mm_and_si128 (in2, _mm_set_epi64x (0, 0xffffffff));
/* Multiply by P(x) */
in2 = _mm_clmulepi64_si128 (mu_poly, in2, 0x01);
/* XOR against input */
in1 = _mm_xor_si128 (in1, in2);
/* Take bits 32-63 as the CRC */
in1 = _mm_srli_si128 (in1, 4);
}
uint32_t final_crc = _mm_cvtsi128_si32 (in1);
return final_crc;
}
+19 -19
View File
@@ -31,7 +31,7 @@ static bool pclmul_checked = false;
#include <string.h>
#if GL_CRC_SLICE_BY_8
#include "crc-sliceby8.h"
# include "crc-sliceby8.h"
/*
* When we calculate the CRC32 byte-by-byte we take the checksum
@@ -76,16 +76,17 @@ crc32_update_no_xor_slice_by_8 (uint32_t crc, const char *buf)
uint64_t local_buf;
memcpy (&local_buf, buf, 8);
local_buf = le64toh (local_buf) ^ crc;
crc = crc32_sliceby8_table[0][(local_buf >> 56) & 0xFF]
^ crc32_sliceby8_table[1][(local_buf >> 48) & 0xFF]
^ crc32_sliceby8_table[2][(local_buf >> 40) & 0xFF]
^ crc32_sliceby8_table[3][(local_buf >> 32) & 0xFF]
^ crc32_sliceby8_table[4][(local_buf >> 24) & 0xFF]
^ crc32_sliceby8_table[5][(local_buf >> 16) & 0xFF]
^ crc32_sliceby8_table[6][(local_buf >> 8) & 0xFF]
^ crc32_sliceby8_table[7][local_buf & 0xFF];
return crc;
uint32_t final_crc = crc32_sliceby8_table[0][(local_buf >> 56) & 0xFF]
^ crc32_sliceby8_table[1][(local_buf >> 48) & 0xFF]
^ crc32_sliceby8_table[2][(local_buf >> 40) & 0xFF]
^ crc32_sliceby8_table[3][(local_buf >> 32) & 0xFF]
^ crc32_sliceby8_table[4][(local_buf >> 24) & 0xFF]
^ crc32_sliceby8_table[5][(local_buf >> 16) & 0xFF]
^ crc32_sliceby8_table[6][(local_buf >> 8) & 0xFF]
^ crc32_sliceby8_table[7][local_buf & 0xFF];
return final_crc;
}
static uint32_t
@@ -93,8 +94,6 @@ crc32_update_no_xor_slice_by_n (uint32_t crc, const char *buf,
size_t num_bytes)
{
uint64_t local_buf;
size_t shift_amount;
memcpy (&local_buf, buf, num_bytes);
local_buf = le64toh (local_buf) ^ crc;
@@ -105,7 +104,7 @@ crc32_update_no_xor_slice_by_n (uint32_t crc, const char *buf,
for (size_t i = 0; i < num_bytes; i++)
{
shift_amount = ((num_bytes - i - 1) * 8);
size_t shift_amount = ((num_bytes - i - 1) * 8);
crc = crc ^ crc32_sliceby8_table[i][(local_buf >> shift_amount) & 0xFF];
}
@@ -115,8 +114,7 @@ crc32_update_no_xor_slice_by_n (uint32_t crc, const char *buf,
uint32_t
crc32_update_no_xor (uint32_t crc, const char *buf, size_t len)
{
size_t n, slice_alignment;
#ifdef GL_CRC_X86_64_PCLMUL
# ifdef GL_CRC_X86_64_PCLMUL
if (!pclmul_checked)
{
pclmul_enabled = (cpu_supports ("pclmul")
@@ -126,10 +124,11 @@ crc32_update_no_xor (uint32_t crc, const char *buf, size_t len)
if (pclmul_enabled && len >= 16)
return crc32_update_no_xor_pclmul (crc, buf, len);
#endif
# endif
slice_alignment = (len & (-8));
size_t slice_alignment = (len & (-8));
size_t n;
for (n = 0; n < slice_alignment; n += 8)
crc = crc32_update_no_xor_slice_by_8 (crc, buf + n);
@@ -138,6 +137,7 @@ crc32_update_no_xor (uint32_t crc, const char *buf, size_t len)
return crc;
}
#else
/* Table of CRCs of all 8-bit messages. Generated by running code
@@ -196,7 +196,7 @@ static const uint32_t crc32_table[256] = {
uint32_t
crc32_update_no_xor (uint32_t crc, const char *buf, size_t len)
{
#ifdef GL_CRC_X86_64_PCLMUL
# ifdef GL_CRC_X86_64_PCLMUL
if (!pclmul_checked)
{
pclmul_enabled = (cpu_supports ("pclmul")
@@ -206,7 +206,7 @@ crc32_update_no_xor (uint32_t crc, const char *buf, size_t len)
if (pclmul_enabled && len >= 16)
return crc32_update_no_xor_pclmul (crc, buf, len);
#endif
# endif
for (size_t n = 0; n < len; n++)
crc = crc32_table[(crc ^ buf[n]) & 0xff] ^ (crc >> 8);
+303 -337
View File
@@ -100,15 +100,13 @@ compile_csharp_using_mono (const char * const *sources,
and (to exclude an unrelated 'mcs' program on QNX 6)
"mcs --version 2>/dev/null | grep Mono >/dev/null" */
const char *argv[3];
pid_t child;
int fd[1];
int exitstatus;
argv[0] = "mcs";
argv[1] = "--version";
argv[2] = NULL;
child = create_pipe_in ("mcs", "mcs", argv, NULL, NULL,
DEV_NULL, true, true, false, fd);
int fd[1];
pid_t child = create_pipe_in ("mcs", "mcs", argv, NULL, NULL,
DEV_NULL, true, true, false, fd);
mcs_present = false;
if (child != -1)
{
@@ -133,7 +131,7 @@ compile_csharp_using_mono (const char * const *sources,
/* Remove zombie process from process list, and retrieve exit
status. */
exitstatus =
int exitstatus =
wait_subprocess (child, "mcs", false, true, true, false, NULL);
if (exitstatus != 0)
mcs_present = false;
@@ -143,70 +141,60 @@ compile_csharp_using_mono (const char * const *sources,
if (mcs_present)
{
unsigned int argc;
const char **argv;
const char **argp;
pid_t child;
int fd[1];
FILE *fp;
char *line[2];
size_t linesize[2];
size_t linelen[2];
unsigned int l;
int exitstatus;
argc =
unsigned int argc =
1 + (output_is_library ? 1 : 0) + 1 + libdirs_count + libraries_count
+ (debug ? 1 : 0) + sources_count;
argv = (const char **) xmalloca ((argc + 1) * sizeof (const char *));
argp = argv;
*argp++ = "mcs";
if (output_is_library)
*argp++ = "-target:library";
const char **argv =
(const char **) xmalloca ((argc + 1) * sizeof (const char *));
{
char *option = (char *) xmalloca (5 + strlen (output_file) + 1);
memcpy (option, "-out:", 5);
strcpy (option + 5, output_file);
*argp++ = option;
}
for (unsigned int i = 0; i < libdirs_count; i++)
const char **argp = argv;
*argp++ = "mcs";
if (output_is_library)
*argp++ = "-target:library";
{
char *option = (char *) xmalloca (5 + strlen (libdirs[i]) + 1);
memcpy (option, "-lib:", 5);
strcpy (option + 5, libdirs[i]);
char *option = (char *) xmalloca (5 + strlen (output_file) + 1);
memcpy (option, "-out:", 5);
strcpy (option + 5, output_file);
*argp++ = option;
}
for (unsigned int i = 0; i < libraries_count; i++)
{
char *option = (char *) xmalloca (11 + strlen (libraries[i]) + 4 + 1);
memcpy (option, "-reference:", 11);
memcpy (option + 11, libraries[i], strlen (libraries[i]));
strcpy (option + 11 + strlen (libraries[i]), ".dll");
*argp++ = option;
}
if (debug)
*argp++ = "-debug";
for (unsigned int i = 0; i < sources_count; i++)
{
const char *source_file = sources[i];
if (strlen (source_file) >= 10
&& memeq (source_file + strlen (source_file) - 10,
".resources", 10))
{
char *option = (char *) xmalloca (10 + strlen (source_file) + 1);
for (unsigned int i = 0; i < libdirs_count; i++)
{
char *option = (char *) xmalloca (5 + strlen (libdirs[i]) + 1);
memcpy (option, "-lib:", 5);
strcpy (option + 5, libdirs[i]);
*argp++ = option;
}
for (unsigned int i = 0; i < libraries_count; i++)
{
char *option = (char *) xmalloca (11 + strlen (libraries[i]) + 4 + 1);
memcpy (option, "-reference:", 11);
memcpy (option + 11, libraries[i], strlen (libraries[i]));
strcpy (option + 11 + strlen (libraries[i]), ".dll");
*argp++ = option;
}
if (debug)
*argp++ = "-debug";
for (unsigned int i = 0; i < sources_count; i++)
{
const char *source_file = sources[i];
if (strlen (source_file) >= 10
&& memeq (source_file + strlen (source_file) - 10,
".resources", 10))
{
char *option = (char *) xmalloca (10 + strlen (source_file) + 1);
memcpy (option, "-resource:", 10);
strcpy (option + 10, source_file);
*argp++ = option;
}
else
*argp++ = source_file;
}
*argp = NULL;
/* Ensure argv length was correctly calculated. */
if (argp - argv != argc)
abort ();
memcpy (option, "-resource:", 10);
strcpy (option + 10, source_file);
*argp++ = option;
}
else
*argp++ = source_file;
}
*argp = NULL;
/* Ensure argv length was correctly calculated. */
if (argp - argv != argc)
abort ();
}
if (verbose)
{
@@ -215,17 +203,21 @@ compile_csharp_using_mono (const char * const *sources,
free (command);
}
child = create_pipe_in ("mcs", "mcs", argv, NULL, NULL,
NULL, false, true, true, fd);
int fd[1];
pid_t child = create_pipe_in ("mcs", "mcs", argv, NULL, NULL,
NULL, false, true, true, fd);
/* Read the subprocess output, copying it to stderr. Drop the last
line if it starts with "Compilation succeeded". */
fp = fdopen (fd[0], "r");
FILE *fp = fdopen (fd[0], "r");
if (fp == NULL)
error (EXIT_FAILURE, errno, _("fdopen() failed"));
char *line[2];
size_t linesize[2];
line[0] = NULL; linesize[0] = 0;
line[1] = NULL; linesize[1] = 0;
l = 0;
unsigned int l = 0;
size_t linelen[2];
for (;;)
{
linelen[l] = getline (&line[l], &linesize[l], fp);
@@ -247,7 +239,7 @@ compile_csharp_using_mono (const char * const *sources,
fclose (fp);
/* Remove zombie process from process list, and retrieve exit status. */
exitstatus =
int exitstatus =
wait_subprocess (child, "mcs", false, false, true, true, NULL);
for (unsigned int i = 1 + (output_is_library ? 1 : 0);
@@ -285,28 +277,26 @@ compile_csharp_using_dotnet (const char * const *sources,
/* Test for presence of dotnet:
dotnet --list-runtimes >/dev/null 2>/dev/null
&& test -n "`dotnet --list-sdks 2>/dev/null`" */
int exitstatus;
int exitstatus1;
{
const char *argv[3];
argv[0] = "dotnet";
argv[1] = "--list-runtimes";
argv[2] = NULL;
exitstatus = execute ("dotnet", "dotnet", argv, NULL, NULL,
false, false, true, true,
true, false, NULL);
exitstatus1 = execute ("dotnet", "dotnet", argv, NULL, NULL,
false, false, true, true,
true, false, NULL);
}
if (exitstatus == 0)
if (exitstatus1 == 0)
{
const char *argv[3];
pid_t child;
int fd[1];
argv[0] = "dotnet";
argv[1] = "--list-sdks";
argv[2] = NULL;
child = create_pipe_in ("dotnet", "dotnet", argv, NULL, NULL,
DEV_NULL, true, true, false, fd);
int fd[1];
pid_t child = create_pipe_in ("dotnet", "dotnet", argv, NULL, NULL,
DEV_NULL, true, true, false, fd);
if (child != -1)
{
/* Read the subprocess output, and test whether it is
@@ -327,7 +317,7 @@ compile_csharp_using_dotnet (const char * const *sources,
/* Remove zombie process from process list, and retrieve exit
status. */
exitstatus =
int exitstatus =
wait_subprocess (child, "dotnet", false, true, true, false,
NULL);
dotnet_present = (exitstatus == 0 && count > 0);
@@ -344,11 +334,9 @@ compile_csharp_using_dotnet (const char * const *sources,
{
bool err = false;
char *dotnet_runtime_dir;
char *dotnet_sdk_dir;
/* Invoke 'dotnet --list-runtimes' and extract the .NET runtime dir
from its output. */
char *dotnet_runtime_dir;
{
dotnet_runtime_dir = NULL;
@@ -441,6 +429,7 @@ compile_csharp_using_dotnet (const char * const *sources,
/* Invoke 'dotnet --list-sdks' and extract the .NET SDK dir
from its output. */
char *dotnet_sdk_dir;
{
dotnet_sdk_dir = NULL;
@@ -529,21 +518,9 @@ compile_csharp_using_dotnet (const char * const *sources,
if (err)
return 1;
struct dirent **dlls;
int num_dlls;
char *roslyn_dir;
char *roslyn_bin_dir;
char *csc;
char *csc_converted;
char **malloced;
char **mallocedp;
unsigned int argc;
const char **argv;
const char **argp;
int exitstatus;
/* Get a list of all *.dll files in dotnet_runtime_dir. */
num_dlls = scandir (dotnet_runtime_dir, &dlls, name_is_dll, alphasort);
struct dirent **dlls;
int num_dlls = scandir (dotnet_runtime_dir, &dlls, name_is_dll, alphasort);
if (num_dlls < 0 && errno == ENOMEM)
xalloc_die ();
if (num_dlls <= 0)
@@ -553,100 +530,102 @@ compile_csharp_using_dotnet (const char * const *sources,
}
/* Construct the file name of the 'csc' compiler. */
roslyn_dir = xconcatenated_filename (dotnet_sdk_dir, "Roslyn", NULL);
roslyn_bin_dir = xconcatenated_filename (roslyn_dir, "bincore", NULL);
csc = xconcatenated_filename (roslyn_bin_dir, "csc.dll", NULL);
csc_converted = cygpath_w (csc);
char *roslyn_dir = xconcatenated_filename (dotnet_sdk_dir, "Roslyn", NULL);
char *roslyn_bin_dir = xconcatenated_filename (roslyn_dir, "bincore", NULL);
char *csc = xconcatenated_filename (roslyn_bin_dir, "csc.dll", NULL);
char *csc_converted = cygpath_w (csc);
/* Here, we assume that 'csc' is a native Windows program, therefore
we need to use cygpath_w. */
malloced =
char **malloced =
(char **)
xmalloca ((1 + libdirs_count + sources_count * 2 + 1) * sizeof (char *));
mallocedp = malloced;
char **mallocedp = malloced;
argc =
unsigned int argc =
3 + 1 + 1 + libdirs_count + libraries_count
+ (optimize ? 1 : 0) + (debug ? 1 : 0) + sources_count + 1 + num_dlls;
argv = (const char **) xmalloca ((argc + 1) * sizeof (const char *));
argp = argv;
*argp++ = "dotnet";
*argp++ = csc_converted;
*argp++ = "-nologo";
*argp++ = (output_is_library ? "-target:library" : "-target:exe");
const char **argv =
(const char **) xmalloca ((argc + 1) * sizeof (const char *));
{
char *output_file_converted = cygpath_w (output_file);
*mallocedp++ = output_file_converted;
char *option = (char *) xmalloca (5 + strlen (output_file_converted) + 1);
memcpy (option, "-out:", 5);
strcpy (option + 5, output_file_converted);
*argp++ = option;
}
for (unsigned int i = 0; i < libdirs_count; i++)
const char **argp = argv;
*argp++ = "dotnet";
*argp++ = csc_converted;
*argp++ = "-nologo";
*argp++ = (output_is_library ? "-target:library" : "-target:exe");
{
const char *libdir = libdirs[i];
char *libdir_converted = cygpath_w (libdir);
*mallocedp++ = libdir_converted;
char *option = (char *) xmalloca (5 + strlen (libdir_converted) + 1);
char *output_file_converted = cygpath_w (output_file);
*mallocedp++ = output_file_converted;
char *option = (char *) xmalloca (5 + strlen (output_file_converted) + 1);
memcpy (option, "-out:", 5);
strcpy (option + 5, output_file_converted);
*argp++ = option;
}
for (unsigned int i = 0; i < libdirs_count; i++)
{
const char *libdir = libdirs[i];
char *libdir_converted = cygpath_w (libdir);
*mallocedp++ = libdir_converted;
char *option = (char *) xmalloca (5 + strlen (libdir_converted) + 1);
memcpy (option, "-lib:", 5);
strcpy (option + 5, libdir_converted);
*argp++ = option;
}
for (unsigned int i = 0; i < libraries_count; i++)
{
char *option = (char *) xmalloca (11 + strlen (libraries[i]) + 4 + 1);
memcpy (option, "-reference:", 11);
memcpy (option + 11, libraries[i], strlen (libraries[i]));
strcpy (option + 11 + strlen (libraries[i]), ".dll");
*argp++ = option;
}
if (optimize)
*argp++ = "-optimize+";
if (debug)
*argp++ = "-debug+";
for (unsigned int i = 0; i < sources_count; i++)
{
const char *source_file = sources[i];
char *source_file_converted = cygpath_w (source_file);
*mallocedp++ = source_file_converted;
if (strlen (source_file_converted) >= 10
&& memeq ((source_file_converted
+ strlen (source_file_converted) - 10),
".resources", 10))
{
char *option =
(char *) xmalloc (10 + strlen (source_file_converted) + 1);
memcpy (option, "-resource:", 10);
strcpy (option + 10, source_file_converted);
*mallocedp++ = option;
*argp++ = option;
}
else
*argp++ = source_file_converted;
}
/* Add -lib and -reference options, so that the compiler finds
Object, Console, String, etc. */
{
char *dotnet_runtime_dir_converted = cygpath_w (dotnet_runtime_dir);
*mallocedp++ = dotnet_runtime_dir_converted;
char *option =
(char *) xmalloca (5 + strlen (dotnet_runtime_dir_converted) + 1);
memcpy (option, "-lib:", 5);
strcpy (option + 5, libdir_converted);
strcpy (option + 5, dotnet_runtime_dir_converted);
*argp++ = option;
}
for (unsigned int i = 0; i < libraries_count; i++)
{
char *option = (char *) xmalloca (11 + strlen (libraries[i]) + 4 + 1);
memcpy (option, "-reference:", 11);
memcpy (option + 11, libraries[i], strlen (libraries[i]));
strcpy (option + 11 + strlen (libraries[i]), ".dll");
*argp++ = option;
}
if (optimize)
*argp++ = "-optimize+";
if (debug)
*argp++ = "-debug+";
for (unsigned int i = 0; i < sources_count; i++)
{
const char *source_file = sources[i];
char *source_file_converted = cygpath_w (source_file);
*mallocedp++ = source_file_converted;
if (strlen (source_file_converted) >= 10
&& memeq ((source_file_converted
+ strlen (source_file_converted) - 10),
".resources", 10))
{
char *option =
(char *) xmalloc (10 + strlen (source_file_converted) + 1);
memcpy (option, "-resource:", 10);
strcpy (option + 10, source_file_converted);
*mallocedp++ = option;
*argp++ = option;
}
else
*argp++ = source_file_converted;
}
/* Add -lib and -reference options, so that the compiler finds
Object, Console, String, etc. */
{
char *dotnet_runtime_dir_converted = cygpath_w (dotnet_runtime_dir);
*mallocedp++ = dotnet_runtime_dir_converted;
char *option =
(char *) xmalloca (5 + strlen (dotnet_runtime_dir_converted) + 1);
memcpy (option, "-lib:", 5);
strcpy (option + 5, dotnet_runtime_dir_converted);
*argp++ = option;
for (unsigned int i = 0; i < num_dlls; i++)
{
char *option = (char *) xmalloca (11 + strlen (dlls[i]->d_name) + 1);
memcpy (option, "-reference:", 11);
strcpy (option + 11, dlls[i]->d_name);
*argp++ = option;
}
*argp = NULL;
/* Ensure argv length was correctly calculated. */
if (argp - argv != argc)
abort ();
}
for (unsigned int i = 0; i < num_dlls; i++)
{
char *option = (char *) xmalloca (11 + strlen (dlls[i]->d_name) + 1);
memcpy (option, "-reference:", 11);
strcpy (option + 11, dlls[i]->d_name);
*argp++ = option;
}
*argp = NULL;
/* Ensure argv length was correctly calculated. */
if (argp - argv != argc)
abort ();
if (verbose)
{
@@ -655,9 +634,9 @@ compile_csharp_using_dotnet (const char * const *sources,
free (command);
}
exitstatus = execute ("dotnet", "dotnet", argv, NULL, NULL,
false, false, false, false,
true, true, NULL);
int exitstatus = execute ("dotnet", "dotnet", argv, NULL, NULL,
false, false, false, false,
true, true, NULL);
for (unsigned int i = 4; i < 5 + libdirs_count + libraries_count; i++)
freea ((char *) argv[i]);
@@ -688,15 +667,13 @@ compile_csharp_using_dotnet (const char * const *sources,
"csc -help 2>/dev/null | grep -i analyzer >/dev/null \
&& ! { csc -help 2>/dev/null | grep -i chicken > /dev/null; }" */
const char *argv[3];
pid_t child;
int fd[1];
int exitstatus;
argv[0] = "csc";
argv[1] = "-help";
argv[2] = NULL;
child = create_pipe_in ("csc", "csc", argv, NULL, NULL,
DEV_NULL, true, true, false, fd);
int fd[1];
pid_t child = create_pipe_in ("csc", "csc", argv, NULL, NULL,
DEV_NULL, true, true, false, fd);
if (child != -1)
{
/* Read the subprocess output, and test whether it contains the
@@ -731,7 +708,7 @@ compile_csharp_using_dotnet (const char * const *sources,
/* Remove zombie process from process list, and retrieve exit
status. */
exitstatus =
int exitstatus =
wait_subprocess (child, "csc", false, true, true, false, NULL);
csc_present = (exitstatus == 0 && seen_analyzer && !seen_chicken);
}
@@ -742,83 +719,78 @@ compile_csharp_using_dotnet (const char * const *sources,
if (csc_present)
{
char **malloced;
char **mallocedp;
unsigned int argc;
const char **argv;
const char **argp;
int exitstatus;
/* Here, we assume that 'csc' is a native Windows program, therefore
we need to use cygpath_w. */
malloced =
char **malloced =
(char **)
xmalloca ((1 + libdirs_count + sources_count * 2) * sizeof (char *));
mallocedp = malloced;
char **mallocedp = malloced;
argc =
unsigned int argc =
2 + 1 + 1 + libdirs_count + libraries_count
+ (optimize ? 1 : 0) + (debug ? 1 : 0) + sources_count;
argv = (const char **) xmalloca ((argc + 1) * sizeof (const char *));
argp = argv;
*argp++ = "csc";
*argp++ = "-nologo";
*argp++ = (output_is_library ? "-target:library" : "-target:exe");
const char **argv =
(const char **) xmalloca ((argc + 1) * sizeof (const char *));
{
char *output_file_converted = cygpath_w (output_file);
*mallocedp++ = output_file_converted;
char *option = (char *) xmalloca (5 + strlen (output_file_converted) + 1);
memcpy (option, "-out:", 5);
strcpy (option + 5, output_file_converted);
*argp++ = option;
const char **argp = argv;
*argp++ = "csc";
*argp++ = "-nologo";
*argp++ = (output_is_library ? "-target:library" : "-target:exe");
{
char *output_file_converted = cygpath_w (output_file);
*mallocedp++ = output_file_converted;
char *option = (char *) xmalloca (5 + strlen (output_file_converted) + 1);
memcpy (option, "-out:", 5);
strcpy (option + 5, output_file_converted);
*argp++ = option;
}
for (unsigned int i = 0; i < libdirs_count; i++)
{
const char *libdir = libdirs[i];
char *libdir_converted = cygpath_w (libdir);
*mallocedp++ = libdir_converted;
char *option = (char *) xmalloca (5 + strlen (libdir_converted) + 1);
memcpy (option, "-lib:", 5);
strcpy (option + 5, libdir_converted);
*argp++ = option;
}
for (unsigned int i = 0; i < libraries_count; i++)
{
char *option = (char *) xmalloca (11 + strlen (libraries[i]) + 4 + 1);
memcpy (option, "-reference:", 11);
memcpy (option + 11, libraries[i], strlen (libraries[i]));
strcpy (option + 11 + strlen (libraries[i]), ".dll");
*argp++ = option;
}
if (optimize)
*argp++ = "-optimize+";
if (debug)
*argp++ = "-debug+";
for (unsigned int i = 0; i < sources_count; i++)
{
const char *source_file = sources[i];
char *source_file_converted = cygpath_w (source_file);
*mallocedp++ = source_file_converted;
if (strlen (source_file_converted) >= 10
&& memeq ((source_file_converted
+ strlen (source_file_converted) - 10),
".resources", 10))
{
char *option =
(char *) xmalloc (10 + strlen (source_file_converted) + 1);
memcpy (option, "-resource:", 10);
strcpy (option + 10, source_file_converted);
*mallocedp++ = option;
*argp++ = option;
}
else
*argp++ = source_file_converted;
}
*argp = NULL;
/* Ensure argv length was correctly calculated. */
if (argp - argv != argc)
abort ();
}
for (unsigned int i = 0; i < libdirs_count; i++)
{
const char *libdir = libdirs[i];
char *libdir_converted = cygpath_w (libdir);
*mallocedp++ = libdir_converted;
char *option = (char *) xmalloca (5 + strlen (libdir_converted) + 1);
memcpy (option, "-lib:", 5);
strcpy (option + 5, libdir_converted);
*argp++ = option;
}
for (unsigned int i = 0; i < libraries_count; i++)
{
char *option = (char *) xmalloca (11 + strlen (libraries[i]) + 4 + 1);
memcpy (option, "-reference:", 11);
memcpy (option + 11, libraries[i], strlen (libraries[i]));
strcpy (option + 11 + strlen (libraries[i]), ".dll");
*argp++ = option;
}
if (optimize)
*argp++ = "-optimize+";
if (debug)
*argp++ = "-debug+";
for (unsigned int i = 0; i < sources_count; i++)
{
const char *source_file = sources[i];
char *source_file_converted = cygpath_w (source_file);
*mallocedp++ = source_file_converted;
if (strlen (source_file_converted) >= 10
&& memeq ((source_file_converted
+ strlen (source_file_converted) - 10),
".resources", 10))
{
char *option =
(char *) xmalloc (10 + strlen (source_file_converted) + 1);
memcpy (option, "-resource:", 10);
strcpy (option + 10, source_file_converted);
*mallocedp++ = option;
*argp++ = option;
}
else
*argp++ = source_file_converted;
}
*argp = NULL;
/* Ensure argv length was correctly calculated. */
if (argp - argv != argc)
abort ();
if (verbose)
{
@@ -827,9 +799,9 @@ compile_csharp_using_dotnet (const char * const *sources,
free (command);
}
exitstatus = execute ("csc", "csc", argv, NULL, NULL,
false, false, false, false,
true, true, NULL);
int exitstatus = execute ("csc", "csc", argv, NULL, NULL,
false, false, false, false,
true, true, NULL);
for (unsigned int i = 3; i < 4 + libdirs_count + libraries_count; i++)
freea ((char *) argv[i]);
@@ -865,15 +837,13 @@ compile_csharp_using_sscli (const char * const *sources,
"csc -help >/dev/null 2>/dev/null \
&& ! { csc -help 2>/dev/null | grep -i chicken > /dev/null; }" */
const char *argv[3];
pid_t child;
int fd[1];
int exitstatus;
argv[0] = "csc";
argv[1] = "-help";
argv[2] = NULL;
child = create_pipe_in ("csc", "csc", argv, NULL, NULL,
DEV_NULL, true, true, false, fd);
int fd[1];
pid_t child = create_pipe_in ("csc", "csc", argv, NULL, NULL,
DEV_NULL, true, true, false, fd);
csc_present = false;
if (child != -1)
{
@@ -902,7 +872,7 @@ compile_csharp_using_sscli (const char * const *sources,
/* Remove zombie process from process list, and retrieve exit
status. */
exitstatus =
int exitstatus =
wait_subprocess (child, "csc", false, true, true, false, NULL);
if (exitstatus != 0)
csc_present = false;
@@ -912,83 +882,78 @@ compile_csharp_using_sscli (const char * const *sources,
if (csc_present)
{
char **malloced;
char **mallocedp;
unsigned int argc;
const char **argv;
const char **argp;
int exitstatus;
/* Here, we assume that 'csc' is a native Windows program, therefore
we need to use cygpath_w. */
malloced =
char **malloced =
(char **)
xmalloca ((1 + libdirs_count + sources_count * 2) * sizeof (char *));
mallocedp = malloced;
char **mallocedp = malloced;
argc =
unsigned int argc =
2 + 1 + 1 + libdirs_count + libraries_count
+ (optimize ? 1 : 0) + (debug ? 1 : 0) + sources_count;
argv = (const char **) xmalloca ((argc + 1) * sizeof (const char *));
argp = argv;
*argp++ = "csc";
*argp++ = "-nologo";
*argp++ = (output_is_library ? "-target:library" : "-target:exe");
const char **argv =
(const char **) xmalloca ((argc + 1) * sizeof (const char *));
{
char *output_file_converted = cygpath_w (output_file);
*mallocedp++ = output_file_converted;
char *option = (char *) xmalloca (5 + strlen (output_file_converted) + 1);
memcpy (option, "-out:", 5);
strcpy (option + 5, output_file_converted);
*argp++ = option;
const char **argp = argv;
*argp++ = "csc";
*argp++ = "-nologo";
*argp++ = (output_is_library ? "-target:library" : "-target:exe");
{
char *output_file_converted = cygpath_w (output_file);
*mallocedp++ = output_file_converted;
char *option = (char *) xmalloca (5 + strlen (output_file_converted) + 1);
memcpy (option, "-out:", 5);
strcpy (option + 5, output_file_converted);
*argp++ = option;
}
for (unsigned int i = 0; i < libdirs_count; i++)
{
const char *libdir = libdirs[i];
char *libdir_converted = cygpath_w (libdir);
*mallocedp++ = libdir_converted;
char *option = (char *) xmalloca (5 + strlen (libdir_converted) + 1);
memcpy (option, "-lib:", 5);
strcpy (option + 5, libdir_converted);
*argp++ = option;
}
for (unsigned int i = 0; i < libraries_count; i++)
{
char *option = (char *) xmalloca (11 + strlen (libraries[i]) + 4 + 1);
memcpy (option, "-reference:", 11);
memcpy (option + 11, libraries[i], strlen (libraries[i]));
strcpy (option + 11 + strlen (libraries[i]), ".dll");
*argp++ = option;
}
if (optimize)
*argp++ = "-optimize+";
if (debug)
*argp++ = "-debug+";
for (unsigned int i = 0; i < sources_count; i++)
{
const char *source_file = sources[i];
char *source_file_converted = cygpath_w (source_file);
*mallocedp++ = source_file_converted;
if (strlen (source_file_converted) >= 10
&& memeq ((source_file_converted
+ strlen (source_file_converted) - 10),
".resources", 10))
{
char *option =
(char *) xmalloc (10 + strlen (source_file_converted) + 1);
memcpy (option, "-resource:", 10);
strcpy (option + 10, source_file_converted);
*mallocedp++ = option;
*argp++ = option;
}
else
*argp++ = source_file_converted;
}
*argp = NULL;
/* Ensure argv length was correctly calculated. */
if (argp - argv != argc)
abort ();
}
for (unsigned int i = 0; i < libdirs_count; i++)
{
const char *libdir = libdirs[i];
char *libdir_converted = cygpath_w (libdir);
*mallocedp++ = libdir_converted;
char *option = (char *) xmalloca (5 + strlen (libdir_converted) + 1);
memcpy (option, "-lib:", 5);
strcpy (option + 5, libdir_converted);
*argp++ = option;
}
for (unsigned int i = 0; i < libraries_count; i++)
{
char *option = (char *) xmalloca (11 + strlen (libraries[i]) + 4 + 1);
memcpy (option, "-reference:", 11);
memcpy (option + 11, libraries[i], strlen (libraries[i]));
strcpy (option + 11 + strlen (libraries[i]), ".dll");
*argp++ = option;
}
if (optimize)
*argp++ = "-optimize+";
if (debug)
*argp++ = "-debug+";
for (unsigned int i = 0; i < sources_count; i++)
{
const char *source_file = sources[i];
char *source_file_converted = cygpath_w (source_file);
*mallocedp++ = source_file_converted;
if (strlen (source_file_converted) >= 10
&& memeq ((source_file_converted
+ strlen (source_file_converted) - 10),
".resources", 10))
{
char *option =
(char *) xmalloc (10 + strlen (source_file_converted) + 1);
memcpy (option, "-resource:", 10);
strcpy (option + 10, source_file_converted);
*mallocedp++ = option;
*argp++ = option;
}
else
*argp++ = source_file_converted;
}
*argp = NULL;
/* Ensure argv length was correctly calculated. */
if (argp - argv != argc)
abort ();
if (verbose)
{
@@ -997,9 +962,9 @@ compile_csharp_using_sscli (const char * const *sources,
free (command);
}
exitstatus = execute ("csc", "csc", argv, NULL, NULL,
false, false, false, false,
true, true, NULL);
int exitstatus = execute ("csc", "csc", argv, NULL, NULL,
false, false, false, false,
true, true, NULL);
for (unsigned int i = 3; i < 4 + libdirs_count + libraries_count; i++)
freea ((char *) argv[i]);
@@ -1028,6 +993,7 @@ compile_csharp_class (const char * const *sources,
bool output_is_library =
(strlen (output_file) >= 4
&& memeq (output_file + strlen (output_file) - 4, ".dll", 4));
int result;
/* First try the C# implementation specified through --enable-csharp. */
+31 -44
View File
@@ -127,28 +127,23 @@ execute_csharp_using_mono (const char *assembly_path,
/* Test for presence of mono:
"mono --version >/dev/null 2>/dev/null" */
const char *argv[3];
int exitstatus;
argv[0] = "mono";
argv[1] = "--version";
argv[2] = NULL;
exitstatus = execute ("mono", "mono", argv, NULL, NULL,
false, false, true, true,
true, false, NULL);
int exitstatus = execute ("mono", "mono", argv, NULL, NULL,
false, false, true, true,
true, false, NULL);
mono_present = (exitstatus == 0);
mono_tested = true;
}
if (mono_present)
{
char *old_monopath;
/* Set MONO_PATH. */
char *old_monopath = set_monopath (libdirs, libdirs_count, false, verbose);
const char **argv =
(const char **) xmalloca ((2 + nargs + 1) * sizeof (const char *));
bool err;
/* Set MONO_PATH. */
old_monopath = set_monopath (libdirs, libdirs_count, false, verbose);
argv[0] = "mono";
argv[1] = assembly_path;
for (unsigned int i = 0; i <= nargs; i++)
@@ -161,13 +156,13 @@ execute_csharp_using_mono (const char *assembly_path,
free (command);
}
err = executer ("mono", "mono", argv, private_data);
bool err = executer ("mono", "mono", argv, private_data);
freea (argv);
/* Reset MONO_PATH. */
reset_monopath (old_monopath);
freea (argv);
return err;
}
else
@@ -190,24 +185,18 @@ execute_csharp_using_dotnet (const char *assembly_path,
/* Test for presence of dotnet:
"dotnet --list-runtimes >/dev/null 2>/dev/null" */
const char *argv[3];
int exitstatus;
argv[0] = "dotnet";
argv[1] = "--list-runtimes";
argv[2] = NULL;
exitstatus = execute ("dotnet", "dotnet", argv, NULL, NULL,
false, false, true, true,
true, false, NULL);
int exitstatus = execute ("dotnet", "dotnet", argv, NULL, NULL,
false, false, true, true,
true, false, NULL);
dotnet_present = (exitstatus == 0);
dotnet_tested = true;
}
if (dotnet_present)
{
bool err = false;
char *assembly_path_converted = cygpath_w (assembly_path);
/* Handle the -L options.
The way this works is that we have to copy (or symlink) the DLLs into
the directory where FOO.exe resides.
@@ -229,11 +218,9 @@ execute_csharp_using_dotnet (const char *assembly_path,
{
const char *libdir = libdirs[l];
struct dirent **dlls;
int num_dlls;
/* Get a list of all *.dll files in libdir. */
num_dlls = scandir (libdir, &dlls, name_is_dll, alphasort);
struct dirent **dlls;
int num_dlls = scandir (libdir, &dlls, name_is_dll, alphasort);
if (num_dlls < 0 && errno == ENOMEM)
xalloc_die ();
if (num_dlls <= 0)
@@ -317,6 +304,10 @@ execute_csharp_using_dotnet (const char *assembly_path,
free (assembly_dir);
}
bool err = false;
char *assembly_path_converted = cygpath_w (assembly_path);
/* Test whether alongside FOO.exe, a file FOO.runtimeconfig.json already
exists. */
char *runtimeconfig_filename =
@@ -337,7 +328,6 @@ execute_csharp_using_dotnet (const char *assembly_path,
{
const char **argv =
(const char **) xmalloca ((3 + nargs + 1) * sizeof (const char *));
argv[0] = "dotnet";
argv[1] = "exec";
argv[2] = assembly_path_converted;
@@ -499,10 +489,10 @@ execute_csharp_using_dotnet (const char *assembly_path,
{
char *runtimeconfig_converted =
cygpath_w (runtimeconfig);
const char **argv =
(const char **)
xmalloca ((5 + nargs + 1) * sizeof (const char *));
argv[0] = "dotnet";
argv[1] = "exec";
argv[2] = "--runtimeconfig";
@@ -563,13 +553,11 @@ execute_csharp_using_sscli (const char *assembly_path,
/* Test for presence of clix:
"clix >/dev/null 2>/dev/null ; test $? = 1" */
const char *argv[2];
int exitstatus;
argv[0] = "clix";
argv[1] = NULL;
exitstatus = execute ("clix", "clix", argv, NULL, NULL,
false, false, true, true,
true, false, NULL);
int exitstatus = execute ("clix", "clix", argv, NULL, NULL,
false, false, true, true,
true, false, NULL);
clix_present = (exitstatus == 0 || exitstatus == 1);
clix_tested = true;
}
@@ -579,14 +567,12 @@ execute_csharp_using_sscli (const char *assembly_path,
/* Here, we assume that 'clix' is a native Windows program, therefore
we need to use cygpath_w. */
char *assembly_path_converted = cygpath_w (assembly_path);
char *old_clixpath;
const char **argv =
(const char **) xmalloca ((2 + nargs + 1) * sizeof (const char *));
bool err;
/* Set clix' PATH variable. */
old_clixpath = set_clixpath (libdirs, libdirs_count, false, verbose);
char *old_clixpath = set_clixpath (libdirs, libdirs_count, false, verbose);
const char **argv =
(const char **) xmalloca ((2 + nargs + 1) * sizeof (const char *));
argv[0] = "clix";
argv[1] = assembly_path_converted;
for (unsigned int i = 0; i <= nargs; i++)
@@ -599,12 +585,13 @@ execute_csharp_using_sscli (const char *assembly_path,
free (command);
}
err = executer ("clix", "clix", argv, private_data);
bool err = executer ("clix", "clix", argv, private_data);
freea (argv);
/* Reset clix' PATH variable. */
reset_clixpath (old_clixpath);
freea (argv);
free (assembly_path_converted);
return err;
@@ -621,10 +608,8 @@ execute_csharp_program (const char *assembly_path,
bool verbose, bool quiet,
execute_fn *executer, void *private_data)
{
unsigned int nargs;
int result;
/* Count args. */
unsigned int nargs;
{
const char * const *arg;
@@ -632,6 +617,8 @@ execute_csharp_program (const char *assembly_path,
;
}
int result;
/* First try the C# implementation specified through --enable-csharp. */
#if CSHARP_CHOICE_MONO
result = execute_csharp_using_mono (assembly_path, libdirs, libdirs_count,
+8 -16
View File
@@ -82,27 +82,22 @@ static char *
execute_and_read_line (const char *progname,
const char *prog_path, const char * const *prog_argv)
{
pid_t child;
int fd[1];
FILE *fp;
char *line;
size_t linesize;
size_t linelen;
/* Open a pipe to the program. */
child = create_pipe_in (progname, prog_path, prog_argv, NULL, NULL,
DEV_NULL, false, true, false, fd);
int fd[1];
pid_t child = create_pipe_in (progname, prog_path, prog_argv, NULL, NULL,
DEV_NULL, false, true, false, fd);
if (child == -1)
return NULL;
/* Retrieve its result. */
fp = fdopen (fd[0], "r");
FILE *fp = fdopen (fd[0], "r");
if (fp == NULL)
error (EXIT_FAILURE, errno, _("fdopen() failed"));
line = NULL; linesize = 0;
linelen = getline (&line, &linesize, fp);
char *line = NULL;
size_t linesize = 0;
size_t linelen = getline (&line, &linesize, fp);
if (linelen == (size_t)(-1))
{
error (0, 0, _("%s subprocess I/O error"), progname);
@@ -111,8 +106,6 @@ execute_and_read_line (const char *progname,
}
else
{
int exitstatus;
if (linelen > 0 && line[linelen - 1] == '\n')
line[linelen - 1] = '\0';
@@ -123,7 +116,7 @@ execute_and_read_line (const char *progname,
fclose (fp);
/* Remove zombie process from process list, and retrieve exit status. */
exitstatus =
int exitstatus =
wait_subprocess (child, progname, true, false, true, false, NULL);
if (exitstatus == 0)
return line;
@@ -136,7 +129,6 @@ char *
cygpath_w (const char *filename)
{
const char *argv[4];
argv[0] = "cygpath";
argv[1] = "-w";
argv[2] = filename;
+6 -8
View File
@@ -320,20 +320,20 @@ bool
gl_des_is_weak_key (const char * key)
{
char work[8];
int left, right, middle, cmp_result;
/* clear parity bits */
for (int i = 0; i < 8; ++i)
work[i] = ((unsigned char)key[i]) & 0xfe;
/* binary search in the weak key table */
left = 0;
right = 63;
int left = 0;
int right = 63;
while (left <= right)
{
middle = (left + right) / 2;
int middle = (left + right) / 2;
if (!(cmp_result = memcmp (work, weak_keys[middle], 8)))
int cmp_result = memcmp (work, weak_keys[middle], 8);
if (!cmp_result)
return -1;
if (cmp_result > 0)
@@ -616,10 +616,8 @@ gl_3des_ecb_crypt (gl_3des_ctx *ctx,
{
const unsigned char *from = (const unsigned char *) _from;
unsigned char *to = (unsigned char *) _to;
uint32_t *keys = mode ? ctx->decrypt_subkeys : ctx->encrypt_subkeys;
uint32_t left, right, work;
uint32_t *keys;
keys = mode ? ctx->decrypt_subkeys : ctx->encrypt_subkeys;
READ_64BIT_DATA (from, left, right)
INITIAL_PERMUTATION (left, work, right)
+31 -25
View File
@@ -1995,18 +1995,20 @@ closure (struct dfa *dfa)
addtok (dfa, PLUS);
if (dfa->lex.minrep == 0)
addtok (dfa, QMARK);
int i;
for (i = 1; i < dfa->lex.minrep; i++)
{
copytoks (dfa, tindex, ntokens);
addtok (dfa, CAT);
}
for (; i < dfa->lex.maxrep; i++)
{
copytoks (dfa, tindex, ntokens);
addtok (dfa, QMARK);
addtok (dfa, CAT);
}
{
int i;
for (i = 1; i < dfa->lex.minrep; i++)
{
copytoks (dfa, tindex, ntokens);
addtok (dfa, CAT);
}
for (; i < dfa->lex.maxrep; i++)
{
copytoks (dfa, tindex, ntokens);
addtok (dfa, QMARK);
addtok (dfa, CAT);
}
}
dfa->parse.tok = lex (dfa);
}
else if (dfa->parse.tok == REPMN)
@@ -4192,12 +4194,11 @@ dfamust (struct dfa const *d)
case OR:
{
char **new;
must *rmp = mp;
assume_nonnull (rmp);
must *lmp = mp = mp->prev;
assume_nonnull (lmp);
idx_t j, ln, rn, n;
idx_t ln, rn, n;
/* Guaranteed to be. Unlikely, but ... */
if (streq (lmp->is, rmp->is))
@@ -4212,23 +4213,28 @@ dfamust (struct dfa const *d)
lmp->endline = false;
}
/* Left side--easy */
idx_t i = 0;
while (lmp->left[i] != '\0' && lmp->left[i] == rmp->left[i])
++i;
lmp->left[i] = '\0';
{
idx_t i = 0;
while (lmp->left[i] != '\0' && lmp->left[i] == rmp->left[i])
++i;
lmp->left[i] = '\0';
}
/* Right side */
ln = strlen (lmp->right);
rn = strlen (rmp->right);
n = ln;
if (n > rn)
n = rn;
for (i = 0; i < n; ++i)
if (lmp->right[ln - i - 1] != rmp->right[rn - i - 1])
break;
for (j = 0; j < i; ++j)
lmp->right[j] = lmp->right[(ln - i) + j];
lmp->right[j] = '\0';
new = inboth (lmp->in, rmp->in);
{
idx_t i, j;
for (i = 0; i < n; ++i)
if (lmp->right[ln - i - 1] != rmp->right[rn - i - 1])
break;
for (j = 0; j < i; ++j)
lmp->right[j] = lmp->right[(ln - i) + j];
lmp->right[j] = '\0';
}
char **new = inboth (lmp->in, rmp->in);
freelist (lmp->in);
free (lmp->in);
lmp->in = new;
+3 -8
View File
@@ -155,7 +155,6 @@ static struct hash_table *
map_device (struct di_set *dis, dev_t dev)
{
/* Find space for the probe, reusing the cache if available. */
struct di_ent *ent;
struct di_ent *probe = dis->probe;
if (probe)
{
@@ -172,7 +171,7 @@ map_device (struct di_set *dis, dev_t dev)
/* Probe for the device. */
probe->dev = dev;
ent = hash_insert (dis->dev_map, probe);
struct di_ent *ent = hash_insert (dis->dev_map, probe);
if (! ent)
return NULL;
@@ -221,15 +220,13 @@ map_inode_number (struct di_set *dis, ino_t ino)
int
di_set_insert (struct di_set *dis, dev_t dev, ino_t ino)
{
hashint i;
/* Map the device number to a set of inodes. */
struct hash_table *ino_set = map_device (dis, dev);
if (! ino_set)
return -1;
/* Map the inode number to a small representative I. */
i = map_inode_number (dis, ino);
hashint i = map_inode_number (dis, ino);
if (i == INO_MAP_INSERT_FAILURE)
return -1;
@@ -243,15 +240,13 @@ di_set_insert (struct di_set *dis, dev_t dev, ino_t ino)
int
di_set_lookup (struct di_set *dis, dev_t dev, ino_t ino)
{
hashint i;
/* Map the device number to a set of inodes. */
struct hash_table *ino_set = map_device (dis, dev);
if (! ino_set)
return -1;
/* Map the inode number to a small representative I. */
i = map_inode_number (dis, ino);
hashint i = map_inode_number (dis, ino);
if (i == INO_MAP_INSERT_FAILURE)
return -1;
+3 -2
View File
@@ -32,7 +32,6 @@ size_t
dir_len (char const *file)
{
size_t prefix_length = FILE_SYSTEM_PREFIX_LEN (file);
size_t length;
/* Advance prefix_length beyond important leading slashes. */
prefix_length += (prefix_length != 0
@@ -45,8 +44,10 @@ dir_len (char const *file)
: 0));
/* Strip the basename and any redundant slashes before it. */
size_t length;
for (length = last_component (file) - file;
prefix_length < length; length--)
prefix_length < length;
length--)
if (! ISSLASH (file[length - 1]))
break;
return length;
+1 -3
View File
@@ -31,10 +31,8 @@ int
dprintf (int fd, const char *format, ...)
{
va_list args;
off64_t ret;
va_start (args, format);
ret = vdzprintf (fd, format, args);
off64_t ret = vdzprintf (fd, format, args);
va_end (args);
if (TYPE_MAXIMUM (off64_t) > INT_MAX && ret > INT_MAX)
+9 -7
View File
@@ -61,17 +61,19 @@ static int
dup_nothrow (int fd)
{
int dupfd;
struct stat sbuf;
dupfd = dup (fd);
if (dupfd == -1 && errno == ENOTSUP \
&& !fstat (fd, &sbuf) && S_ISDIR (sbuf.st_mode))
if (dupfd == -1 && errno == ENOTSUP)
{
char path[_MAX_PATH];
struct stat sbuf;
if (!fstat (fd, &sbuf) && S_ISDIR (sbuf.st_mode))
{
char path[_MAX_PATH];
/* Get a path from fd */
if (!__libc_Back_ioFHToPath (fd, path, sizeof (path)))
dupfd = open (path, O_RDONLY);
/* Get a path from fd */
if (!__libc_Back_ioFHToPath (fd, path, sizeof (path)))
dupfd = open (path, O_RDONLY);
}
}
return dupfd;
+15 -18
View File
@@ -70,8 +70,6 @@ dup2_nothrow (int fd, int desired_fd)
static int
ms_windows_dup2 (int fd, int desired_fd)
{
int result;
/* If fd is closed, mingw hangs on dup2 (fd, fd). If fd is open,
dup2 (fd, fd) returns 0, but all further attempts to use fd in
future dup2 calls will hang. */
@@ -93,7 +91,7 @@ ms_windows_dup2 (int fd, int desired_fd)
return -1;
}
result = dup2_nothrow (fd, desired_fd);
int result = dup2_nothrow (fd, desired_fd);
if (result == 0)
result = desired_fd;
@@ -110,10 +108,7 @@ ms_windows_dup2 (int fd, int desired_fd)
static int
klibc_dup2dirfd (int fd, int desired_fd)
{
int tempfd;
int dupfd;
tempfd = open ("NUL", O_RDONLY);
int tempfd = open ("NUL", O_RDONLY);
if (tempfd < 0)
return tempfd;
@@ -129,7 +124,7 @@ klibc_dup2dirfd (int fd, int desired_fd)
{
close (desired_fd);
dupfd = open (path, O_RDONLY);
int dupfd = open (path, O_RDONLY);
if (dupfd < 0)
return dupfd;
@@ -150,7 +145,7 @@ klibc_dup2dirfd (int fd, int desired_fd)
}
}
dupfd = klibc_dup2dirfd (fd, desired_fd);
int dupfd = klibc_dup2dirfd (fd, desired_fd);
close (tempfd);
@@ -160,13 +155,17 @@ klibc_dup2dirfd (int fd, int desired_fd)
static int
klibc_dup2 (int fd, int desired_fd)
{
int dupfd;
struct stat sbuf;
int dupfd = dup2 (fd, desired_fd);
if (dupfd < 0 && errno == ENOTSUP)
{
struct stat sbuf;
if (!fstat (fd, &sbuf) && S_ISDIR (sbuf.st_mode))
{
close (desired_fd);
dupfd = dup2 (fd, desired_fd);
if (dupfd < 0 && errno == ENOTSUP \
&& !fstat (fd, &sbuf) && S_ISDIR (sbuf.st_mode))
return klibc_dup2dirfd (fd, desired_fd);
return klibc_dup2dirfd (fd, desired_fd);
}
}
return dupfd;
}
@@ -177,8 +176,6 @@ klibc_dup2 (int fd, int desired_fd)
int
rpl_dup2 (int fd, int desired_fd)
{
int result;
#ifdef F_GETFL
/* On Linux kernels 2.6.26-2.6.29, dup2 (fd, fd) returns -EBADF.
On Cygwin 1.5.x, dup2 (1, 1) returns 0.
@@ -194,7 +191,7 @@ rpl_dup2 (int fd, int desired_fd)
return fcntl (fd, F_GETFL) == -1 ? -1 : fd;
#endif
result = dup2 (fd, desired_fd);
int result = dup2 (fd, desired_fd);
/* Correct an errno value on FreeBSD 6.1 and Cygwin 1.5.x. */
if (result < 0 && errno == EMFILE)
+1 -2
View File
@@ -90,9 +90,8 @@ dup3 (int oldfd, int newfd, int flags)
if (flags & O_CLOEXEC)
{
int result;
close (newfd);
result = fcntl (oldfd, F_DUPFD_CLOEXEC, newfd);
int result = fcntl (oldfd, F_DUPFD_CLOEXEC, newfd);
if (newfd < result)
{
close (result);
+38 -33
View File
@@ -69,16 +69,16 @@ duplocale (locale_t locale)
#endif
};
char base_name[SETLOCALE_NULL_MAX];
int err;
locale_t base_copy;
err = setlocale_null_r (LC_CTYPE, base_name, sizeof (base_name));
if (err)
{
errno = err;
return NULL;
}
base_copy = newlocale (LC_ALL_MASK, base_name, NULL);
{
int err = setlocale_null_r (LC_CTYPE, base_name, sizeof (base_name));
if (err)
{
errno = err;
return NULL;
}
}
locale_t base_copy = newlocale (LC_ALL_MASK, base_name, NULL);
if (base_copy == NULL)
return NULL;
@@ -88,12 +88,14 @@ duplocale (locale_t locale)
int category_mask = categories[i].mask;
char name[SETLOCALE_NULL_MAX];
err = setlocale_null_r (category, name, sizeof (name));
if (err)
{
errno = err;
return NULL;
}
{
int err = setlocale_null_r (category, name, sizeof (name));
if (err)
{
errno = err;
return NULL;
}
}
if (!streq (name, base_name))
{
locale_t copy = newlocale (category_mask, name, base_copy);
@@ -122,11 +124,10 @@ duplocale (locale_t locale)
return NULL;
}
int i;
int err;
for (i = 0; i < 6; i++)
for (int i = 0; i < 6; i++)
{
int log2_lcmask = gl_index_to_log2_lcmask (i);
int err;
result->category[i].name = strdup (locale->category[i].name);
if (result->category[i].name == NULL)
@@ -158,26 +159,30 @@ duplocale (locale_t locale)
}
}
# endif
if (0)
fail_with_err:
{
while (--i >= 0)
{
# if HAVE_WINDOWS_LOCALE_T
if (!(i == gl_log2_lcmask_to_index (gl_log2_lc_mask (LC_MESSAGES))
|| result->category[i].is_c_locale))
/* Documentation:
<https://learn.microsoft.com/en-us/cpp/c-runtime-library/reference/free-locale> */
_free_locale (result->category[i].system_locale);
# endif
free (result->category[i].name);
}
free (result);
errno = err;
return NULL;
}
}
/* Success. */
return result;
fail_with_err:
while (--i >= 0)
{
# if HAVE_WINDOWS_LOCALE_T
if (!(i == gl_log2_lcmask_to_index (gl_log2_lc_mask (LC_MESSAGES))
|| result->category[i].is_c_locale))
/* Documentation:
<https://learn.microsoft.com/en-us/cpp/c-runtime-library/reference/free-locale> */
_free_locale (result->category[i].system_locale);
# endif
free (result->category[i].name);
}
free (result);
errno = err;
return NULL;
#else
+6 -7
View File
@@ -33,14 +33,13 @@ off64_t
dzprintf (int fd, const char *format, ...)
{
va_list args;
char buf[2000];
char *output;
size_t len;
size_t lenbuf = sizeof (buf);
va_start (args, format);
output = vasnprintf (buf, &lenbuf, format, args);
len = lenbuf;
char buf[2000];
size_t lenbuf = sizeof (buf);
char *output = vasnprintf (buf, &lenbuf, format, args);
size_t len = lenbuf;
va_end (args);
if (!output)
+6 -13
View File
@@ -111,16 +111,13 @@ euidaccess (const char *file, int mode)
}
else
{
int result;
int saved_errno;
if (uid != euid)
setreuid (euid, uid);
if (gid != egid)
setregid (egid, gid);
result = access (file, mode);
saved_errno = errno;
int result = access (file, mode);
int saved_errno = errno;
/* Restore them. */
if (uid != euid)
@@ -138,7 +135,6 @@ euidaccess (const char *file, int mode)
correct on systems that have ACLs or the like. However, it's
better than nothing, and it is reentrant. */
unsigned int granted;
if (uid == euid && gid == egid)
/* If we are not set-uid or set-gid, access does the same. */
return access (file, mode);
@@ -165,6 +161,7 @@ euidaccess (const char *file, int mode)
return 0; /* The file exists. */
/* Convert the file's permission bits to traditional form. */
unsigned int granted;
if (S_IRUSR == (4 << 6) && S_IWUSR == (2 << 6) && S_IXUSR == (1 << 6)
&& S_IRGRP == (4 << 3) && S_IWGRP == (2 << 3) && S_IXGRP == (1 << 3)
&& S_IROTH == (4 << 0) && S_IWOTH == (2 << 0) && S_IXOTH == (1 << 0))
@@ -206,16 +203,12 @@ weak_alias (__euidaccess, euidaccess)
int
main (int argc, char **argv)
{
char *file;
int mode;
int err;
if (argc < 3)
abort ();
file = argv[1];
mode = atoi (argv[2]);
char *file = argv[1];
int mode = atoi (argv[2]);
err = euidaccess (file, mode);
int err = euidaccess (file, mode);
printf ("%d\n", err);
if (err != 0)
error (0, errno, "%s", file);
+1 -1
View File
@@ -524,10 +524,10 @@ add_exclude (struct exclude *ex, char const *pattern, int options)
patopts->options = options;
if (options & EXCLUDE_REGEX)
{
int rc;
int cflags = (REG_NOSUB | REG_EXTENDED
| (options & FNM_CASEFOLD ? REG_ICASE : 0));
int rc;
if (! (options & FNM_LEADING_DIR))
rc = regcomp (&patopts->v.re, pattern, cflags);
else
+12 -10
View File
@@ -33,8 +33,6 @@
int
execl (const char *program, const char *arg0, ...)
{
va_list args;
/* The callee is not expecting a NULL argv[0]. */
if (arg0 == NULL)
{
@@ -44,14 +42,17 @@ execl (const char *program, const char *arg0, ...)
/* Count the number of arguments (including arg0 and the trailing NULL). */
size_t count = 1;
va_start (args, arg0);
for (;;)
{
count++;
if (va_arg (args, const char *) == NULL)
break;
}
va_end (args);
{
va_list args;
va_start (args, arg0);
for (;;)
{
count++;
if (va_arg (args, const char *) == NULL)
break;
}
va_end (args);
}
/* Allocate the argument vector. */
const char **argv = (const char **) malloca (count * sizeof (const char *));
@@ -65,6 +66,7 @@ execl (const char *program, const char *arg0, ...)
{
size_t i = 0;
argv[i++] = arg0;
va_list args;
va_start (args, arg0);
for (; i < count;)
argv[i++] = va_arg (args, const char *);
+12 -9
View File
@@ -33,7 +33,6 @@
int
execle (const char *program, const char *arg0, ...)
{
va_list args;
/* The callee is not expecting a NULL argv[0]. */
if (arg0 == NULL)
@@ -44,14 +43,17 @@ execle (const char *program, const char *arg0, ...)
/* Count the number of arguments (including arg0 and the trailing NULL). */
size_t count = 1;
va_start (args, arg0);
for (;;)
{
count++;
if (va_arg (args, const char *) == NULL)
break;
}
va_end (args);
{
va_list args;
va_start (args, arg0);
for (;;)
{
count++;
if (va_arg (args, const char *) == NULL)
break;
}
va_end (args);
}
/* Allocate the argument vector. */
const char **argv = (const char **) malloca (count * sizeof (const char *));
@@ -62,6 +64,7 @@ execle (const char *program, const char *arg0, ...)
}
/* Copy the arguments into the argument vector. */
va_list args;
{
size_t i = 0;
argv[i++] = arg0;
+12 -10
View File
@@ -33,8 +33,6 @@
int
execlp (const char *program, const char *arg0, ...)
{
va_list args;
/* The callee is not expecting a NULL argv[0]. */
if (arg0 == NULL)
{
@@ -44,14 +42,17 @@ execlp (const char *program, const char *arg0, ...)
/* Count the number of arguments (including arg0 and the trailing NULL). */
size_t count = 1;
va_start (args, arg0);
for (;;)
{
count++;
if (va_arg (args, const char *) == NULL)
break;
}
va_end (args);
{
va_list args;
va_start (args, arg0);
for (;;)
{
count++;
if (va_arg (args, const char *) == NULL)
break;
}
va_end (args);
}
/* Allocate the argument vector. */
const char **argv = (const char **) malloca (count * sizeof (const char *));
@@ -65,6 +66,7 @@ execlp (const char *program, const char *arg0, ...)
{
size_t i = 0;
argv[i++] = arg0;
va_list args;
va_start (args, arg0);
for (; i < count;)
argv[i++] = va_arg (args, const char *);
+2 -1
View File
@@ -121,7 +121,6 @@ execute (const char *progname,
bool slave_process, bool exit_on_error,
int *termsigp)
{
int saved_errno;
char *prog_path_to_free = NULL;
if (directory != NULL)
@@ -170,6 +169,8 @@ execute (const char *progname,
}
}
int saved_errno;
#if (defined _WIN32 && !defined __CYGWIN__) && EXECUTE_IMPL_AVOID_POSIX_SPAWN
/* Native Windows API. */
+6 -12
View File
@@ -62,13 +62,10 @@ ensure_dirs_slot (size_t fd)
free (dirs[fd].name);
else
{
size_t new_allocated;
dir_info_t *new_dirs;
new_allocated = 2 * dirs_allocated + 1;
size_t new_allocated = 2 * dirs_allocated + 1;
if (new_allocated <= fd)
new_allocated = fd + 1;
new_dirs =
dir_info_t *new_dirs =
(dirs != NULL
? (dir_info_t *) realloc (dirs, new_allocated * sizeof *dirs)
: (dir_info_t *) malloc (new_allocated * sizeof *dirs));
@@ -87,18 +84,15 @@ ensure_dirs_slot (size_t fd)
static char *
get_name (char const *dir)
{
char *cwd;
char *result;
if (IS_ABSOLUTE_FILE_NAME (dir))
return strdup (dir);
/* We often encounter "."; treat it as a special case. */
cwd = getcwd (NULL, 0);
char *cwd = getcwd (NULL, 0);
if (!cwd || (dir[0] == '.' && dir[1] == '\0'))
return cwd;
result = mfile_name_concat (cwd, dir, NULL);
char *result = mfile_name_concat (cwd, dir, NULL);
free (cwd);
return result;
}
@@ -126,9 +120,9 @@ _gl_unregister_fd (int fd)
int
_gl_register_fd (int fd, const char *filename)
{
struct stat statbuf;
assure (0 <= fd);
struct stat statbuf;
if (REPLACE_OPEN_DIRECTORY
|| (fstat (fd, &statbuf) == 0 && S_ISDIR (statbuf.st_mode)))
{
+3 -3
View File
@@ -58,11 +58,9 @@ int
rpl_fclose (FILE *fp)
{
int saved_errno = 0;
int fd;
int result = 0;
/* Don't change behavior on memstreams. */
fd = fileno (fp);
int fd = fileno (fp);
if (fd < 0)
return fclose_nothrow (fp);
@@ -73,6 +71,8 @@ rpl_fclose (FILE *fp)
&& fflush (fp))
saved_errno = errno;
int result = 0;
/* fclose() calls close(), but we need to also invoke all hooks that our
overridden close() function invokes. See lib/close.c. */
#if WINDOWS_SOCKETS
+80 -78
View File
@@ -56,19 +56,15 @@ dupfd (int oldfd, int newfd, int flags)
{
/* Mingw has no way to create an arbitrary fd. Iterate until all
file descriptors less than newfd are filled up. */
HANDLE curr_process = GetCurrentProcess ();
HANDLE old_handle = (HANDLE) _get_osfhandle (oldfd);
unsigned char fds_to_close[OPEN_MAX_MAX / CHAR_BIT];
unsigned int fds_to_close_bound = 0;
int result;
BOOL inherit = flags & O_CLOEXEC ? FALSE : TRUE;
int mode;
if (newfd < 0 || getdtablesize () <= newfd)
{
errno = EINVAL;
return -1;
}
HANDLE old_handle = (HANDLE) _get_osfhandle (oldfd);
int mode;
if (old_handle == INVALID_HANDLE_VALUE
|| (mode = _setmode (oldfd, O_BINARY)) == -1)
{
@@ -80,6 +76,11 @@ dupfd (int oldfd, int newfd, int flags)
_setmode (oldfd, mode);
flags |= mode;
HANDLE curr_process = GetCurrentProcess ();
BOOL inherit = flags & O_CLOEXEC ? FALSE : TRUE;
unsigned char fds_to_close[OPEN_MAX_MAX / CHAR_BIT];
unsigned int fds_to_close_bound = 0;
int result;
for (;;)
{
HANDLE new_handle;
@@ -205,8 +206,9 @@ fcntl (int fd, int action, /* arg */...)
#endif
{
va_list arg;
int result = -1;
va_start (arg, action);
int result = -1;
switch (action)
{
case F_DUPFD:
@@ -432,7 +434,9 @@ fcntl (int fd, int action, /* arg */...)
break;
}
}
va_end (arg);
return result;
}
@@ -542,10 +546,7 @@ rpl_fcntl_DUPFD_CLOEXEC (int fd, int target)
static int
klibc_dupdirfd (int fd, int minfd)
{
int tempfd;
int dupfd;
tempfd = open ("NUL", O_RDONLY);
int tempfd = open ("NUL", O_RDONLY);
if (tempfd == -1)
return -1;
@@ -557,7 +558,7 @@ klibc_dupdirfd (int fd, int minfd)
if (__libc_Back_ioFHToPath (fd, path, sizeof (path)))
return -1;
dupfd = open (path, O_RDONLY);
int dupfd = open (path, O_RDONLY);
if (dupfd == -1)
return -1;
@@ -568,7 +569,7 @@ klibc_dupdirfd (int fd, int minfd)
tempfd = dupfd;
}
dupfd = klibc_dupdirfd (fd, minfd);
int dupfd = klibc_dupdirfd (fd, minfd);
close (tempfd);
@@ -579,77 +580,78 @@ static int
klibc_fcntl (int fd, int action, /* arg */...)
{
va_list arg_ptr;
int arg;
struct stat sbuf;
int result;
va_start (arg_ptr, action);
arg = va_arg (arg_ptr, int);
result = fcntl (fd, action, arg);
int arg = va_arg (arg_ptr, int);
int result = fcntl (fd, action, arg);
/* EPERM for F_DUPFD, ENOTSUP for others */
if (result == -1 && (errno == EPERM || errno == ENOTSUP)
&& !fstat (fd, &sbuf) && S_ISDIR (sbuf.st_mode))
if (result == -1 && (errno == EPERM || errno == ENOTSUP))
{
PLIBCFH pFH;
unsigned fFlags;
switch (action)
struct stat sbuf;
if (!fstat (fd, &sbuf) && S_ISDIR (sbuf.st_mode))
{
case F_DUPFD:
result = klibc_dupdirfd (fd, arg);
break;
case F_GETFD:
pFH = __libc_FH (fd);
if (!pFH)
switch (action)
{
errno = EBADF;
case F_DUPFD:
result = klibc_dupdirfd (fd, arg);
break;
case F_GETFD:
{
PLIBCFH pFH = __libc_FH (fd);
if (!pFH)
{
errno = EBADF;
break;
}
result = (pFH->fFlags & ((FD_CLOEXEC << __LIBC_FH_FDFLAGS_SHIFT )
| O_NOINHERIT)) ? FD_CLOEXEC : 0;
}
break;
case F_SETFD:
{
if (arg & ~FD_CLOEXEC)
break;
PLIBCFH pFH = __libc_FH (fd);
if (!pFH)
{
errno = EBADF;
break;
}
unsigned fFlags = pFH->fFlags;
if (arg & FD_CLOEXEC)
fFlags |= (FD_CLOEXEC << __LIBC_FH_FDFLAGS_SHIFT) | O_NOINHERIT;
else
fFlags &= ~((FD_CLOEXEC << __LIBC_FH_FDFLAGS_SHIFT) | O_NOINHERIT);
result = __libc_FHSetFlags (pFH, fd, fFlags);
if (result < 0)
{
errno = -result;
result = -1;
}
}
break;
case F_GETFL:
result = 0;
break;
case F_SETFL:
if (arg != 0)
break;
result = 0;
break;
default:
errno = EINVAL;
break;
}
result = (pFH->fFlags & ((FD_CLOEXEC << __LIBC_FH_FDFLAGS_SHIFT )
| O_NOINHERIT)) ? FD_CLOEXEC : 0;
break;
case F_SETFD:
if (arg & ~FD_CLOEXEC)
break;
pFH = __libc_FH (fd);
if (!pFH)
{
errno = EBADF;
break;
}
fFlags = pFH->fFlags;
if (arg & FD_CLOEXEC)
fFlags |= (FD_CLOEXEC << __LIBC_FH_FDFLAGS_SHIFT) | O_NOINHERIT;
else
fFlags &= ~((FD_CLOEXEC << __LIBC_FH_FDFLAGS_SHIFT) | O_NOINHERIT);
result = __libc_FHSetFlags (pFH, fd, fFlags);
if (result < 0)
{
errno = -result;
result = -1;
}
break;
case F_GETFL:
result = 0;
break;
case F_SETFL:
if (arg != 0)
break;
result = 0;
break;
default:
errno = EINVAL;
break;
}
}
+1 -2
View File
@@ -57,10 +57,9 @@ FILE *
rpl_fdopen (int fd, const char *mode)
{
int saved_errno = errno;
FILE *fp;
errno = 0;
fp = fdopen_nothrow (fd, mode);
FILE *fp = fdopen_nothrow (fd, mode);
if (fp == NULL)
{
if (errno == 0)
+7 -11
View File
@@ -161,7 +161,6 @@ aclinfo_has_xattr (struct aclinfo const *ai, char const *xattr)
static void
get_aclinfo (int fd, char const *name, struct aclinfo *ai, int flags)
{
int scontext_err = ENOTSUP;
ai->buf = ai->u.__gl_acl_ch;
ssize_t acl_alloc = sizeof ai->u.__gl_acl_ch;
@@ -221,6 +220,7 @@ get_aclinfo (int fd, char const *name, struct aclinfo *ai, int flags)
}
/* A security context can exist only if extended attributes do. */
int scontext_err = ENOTSUP;
if (flags & ACL_GET_SCONTEXT
&& (0 < ai->size || aclinfo_may_indicate_xattr (ai)))
{
@@ -781,11 +781,9 @@ fdfile_has_aclinfo (MAYBE_UNUSED int fd,
{
struct acl_entry entries[NACLENTRIES];
int count;
count = (fd < 0
? getacl (name, NACLENTRIES, entries)
: fgetacl (fd, NACLENTRIES, entries));
int count = (fd < 0
? getacl (name, NACLENTRIES, entries)
: fgetacl (fd, NACLENTRIES, entries));
if (count < 0)
{
@@ -827,10 +825,9 @@ fdfile_has_aclinfo (MAYBE_UNUSED int fd,
{
struct acl entries[NACLVENTRIES];
int count;
/* Ignore FD, unfortunately. */
count = acl ((char *) name, ACL_GET, NACLVENTRIES, entries);
int count = acl ((char *) name, ACL_GET, NACLVENTRIES, entries);
if (count < 0)
{
@@ -867,13 +864,13 @@ fdfile_has_aclinfo (MAYBE_UNUSED int fd,
char aclbuf[1024];
void *acl = aclbuf;
size_t aclsize = sizeof (aclbuf);
mode_t mode;
for (;;)
{
/* The docs say that type being 0 is equivalent to ACL_ANY, but it
is not true, in AIX 5.3. */
type.u64 = ACL_ANY;
mode_t mode;
if (0 <= (fd < 0
? aclx_get (name, 0, &type, aclbuf, &aclsize, &mode)
: aclx_fget (fd, 0, &type, aclbuf, &aclsize, &mode)))
@@ -934,10 +931,9 @@ fdfile_has_aclinfo (MAYBE_UNUSED int fd,
{
struct acl entries[NACLENTRIES];
int count;
/* Ignore FD, unfortunately. */
count = acl ((char *) name, ACL_GET, NACLENTRIES, entries);
int count = acl ((char *) name, ACL_GET, NACLENTRIES, entries);
if (count < 0)
{
+1 -3
View File
@@ -305,9 +305,7 @@ file_is_remote (const char *file)
int
main (int argc, char *argv[])
{
int i;
for (i = 1; i < argc; i++)
for (int i = 1; i < argc; i++)
{
const char *file = argv[i];
int ret = file_is_remote (file);
+2 -4
View File
@@ -28,12 +28,10 @@
void
record_file (Hash_table *ht, char const *file, struct stat const *stats)
{
struct F_triple *ent;
if (ht == NULL)
return;
ent = xmalloc (sizeof *ent);
struct F_triple *ent = xmalloc (sizeof *ent);
ent->name = xstrdup (file);
ent->st_ino = stats->st_ino;
ent->st_dev = stats->st_dev;
@@ -61,11 +59,11 @@ bool
seen_file (Hash_table const *ht, char const *file,
struct stat const *stats)
{
struct F_triple new_ent;
if (ht == NULL)
return false;
struct F_triple new_ent;
new_ent.name = (char *) file;
new_ent.st_ino = stats->st_ino;
new_ent.st_dev = stats->st_dev;
+11 -18
View File
@@ -94,17 +94,13 @@ find_in_given_path (const char *progname, const char *path,
{
/* Try the various suffixes and see whether one of the files
with such a suffix is actually executable. */
int failure_errno;
const char *directory_as_prefix =
(directory != NULL && IS_RELATIVE_FILE_NAME (progname)
? directory
: "");
#if defined _WIN32 && !defined __CYGWIN__ /* Native Windows */
const char *progbasename;
progbasename = progname;
const char *progbasename = progname;
for (const char *p = progname; *p != '\0'; p++)
if (ISSLASH (*p))
progbasename = p + 1;
@@ -113,7 +109,7 @@ find_in_given_path (const char *progname, const char *path,
#endif
/* Try all platform-dependent suffixes. */
failure_errno = ENOENT;
int failure_errno = ENOENT;
for (size_t i = 0; i < sizeof (suffixes) / sizeof (suffixes[0]); i++)
{
const char *suffix = suffixes[i];
@@ -214,26 +210,19 @@ find_in_given_path (const char *progname, const char *path,
if (path_copy == NULL)
return NULL; /* errno is set here */
int failure_errno;
char *cp;
#if defined _WIN32 && !defined __CYGWIN__ /* Native Windows */
bool progname_has_dot = (strchr (progname, '.') != NULL);
#endif
failure_errno = ENOENT;
for (char *path_rest = path_copy; ; path_rest = cp + 1)
int failure_errno = ENOENT;
for (char *path_rest = path_copy; ; )
{
const char *dir;
bool last;
char *dir_as_prefix_to_free;
const char *dir_as_prefix;
/* Extract next directory in PATH. */
dir = path_rest;
const char *dir = path_rest;
char *cp;
for (cp = path_rest; *cp != '\0' && *cp != PATH_SEPARATOR; cp++)
;
last = (*cp == '\0');
bool last = (*cp == '\0');
*cp = '\0';
/* Empty PATH components designate the current directory. */
@@ -241,6 +230,8 @@ find_in_given_path (const char *progname, const char *path,
dir = ".";
/* Concatenate directory and dir. */
char *dir_as_prefix_to_free;
const char *dir_as_prefix;
if (directory != NULL && IS_RELATIVE_FILE_NAME (dir))
{
dir_as_prefix_to_free =
@@ -375,6 +366,8 @@ find_in_given_path (const char *progname, const char *path,
if (last)
break;
path_rest = cp + 1;
}
failed:
+8 -11
View File
@@ -47,15 +47,12 @@ find_in_path (const char *progname)
return progname;
#else
/* Unix */
char *path;
char *cp;
if (strchr (progname, '/') != NULL)
/* If progname contains a slash, it is either absolute or relative to
the current directory. PATH is not used. */
return progname;
path = getenv ("PATH");
char *path = getenv ("PATH");
if (path == NULL || *path == '\0')
/* If PATH is not set, the default search path is implementation
dependent. */
@@ -70,17 +67,14 @@ find_in_path (const char *progname)
/* Out of memory. */
return progname;
# endif
for (char *path_rest = path; ; path_rest = cp + 1)
for (char *path_rest = path; ; )
{
const char *dir;
bool last;
char *progpathname;
/* Extract next directory in PATH. */
dir = path_rest;
const char *dir = path_rest;
char *cp;
for (cp = path_rest; *cp != '\0' && *cp != ':'; cp++)
;
last = (*cp == '\0');
bool last = (*cp == '\0');
*cp = '\0';
/* Empty PATH components designate the current directory. */
@@ -88,6 +82,7 @@ find_in_path (const char *progname)
dir = ".";
/* Concatenate dir and progname. */
char *progpathname;
# if !IN_FINDPROG_LGPL
progpathname = xconcatenated_filename (dir, progname, NULL);
# else
@@ -145,6 +140,8 @@ find_in_path (const char *progname)
if (last)
break;
path_rest = cp + 1;
}
/* Not found in PATH. An error will be signalled at the first call. */
+10 -17
View File
@@ -59,19 +59,17 @@ file_size (HANDLE h, DWORD * lower, DWORD * upper)
static BOOL
do_lock (HANDLE h, int non_blocking, int exclusive)
{
BOOL res;
DWORD size_lower, size_upper;
OVERLAPPED ovlp;
int flags = 0;
/* We're going to lock the whole file, so get the file size. */
res = file_size (h, &size_lower, &size_upper);
DWORD size_lower, size_upper;
BOOL res = file_size (h, &size_lower, &size_upper);
if (!res)
return 0;
/* Start offset is 0, and also zero the remaining members of this struct. */
OVERLAPPED ovlp;
memset (&ovlp, 0, sizeof ovlp);
int flags = 0;
if (non_blocking)
flags |= LOCKFILE_FAIL_IMMEDIATELY;
if (exclusive)
@@ -84,10 +82,8 @@ do_lock (HANDLE h, int non_blocking, int exclusive)
static BOOL
do_unlock (HANDLE h)
{
int res;
DWORD size_lower, size_upper;
res = file_size (h, &size_lower, &size_upper);
int res = file_size (h, &size_lower, &size_upper);
if (!res)
return 0;
@@ -99,18 +95,16 @@ int
flock (int fd, int operation)
{
HANDLE h = (HANDLE) _get_osfhandle (fd);
DWORD res;
int non_blocking;
if (h == INVALID_HANDLE_VALUE)
{
errno = EBADF;
return -1;
}
non_blocking = operation & LOCK_NB;
int non_blocking = operation & LOCK_NB;
operation &= ~LOCK_NB;
DWORD res;
switch (operation)
{
case LOCK_SH:
@@ -179,15 +173,14 @@ flock (int fd, int operation)
int
flock (int fd, int operation)
{
int cmd, r;
struct flock fl;
int cmd;
if (operation & LOCK_NB)
cmd = F_SETLK;
else
cmd = F_SETLKW;
operation &= ~LOCK_NB;
struct flock fl;
memset (&fl, 0, sizeof fl);
fl.l_whence = SEEK_SET;
/* l_start & l_len are 0, which as a special case means "whole file". */
@@ -208,7 +201,7 @@ flock (int fd, int operation)
return -1;
}
r = fcntl (fd, cmd, &fl);
int r = fcntl (fd, cmd, &fl);
if (r == -1 && errno == EACCES)
errno = EAGAIN;
+5 -10
View File
@@ -128,9 +128,8 @@ decode (DOUBLE x, mp_limb_t limbs[NLIMBS1])
{
/* Here we still have MANT_BIT-0*31 bits to extract from x. */
enum { chunk_bits = MIN (31, MANT_BIT - 0 * 31) }; /* > 0, <= 31 */
mp_limb_t d;
x *= (mp_limb_t) 1 << chunk_bits;
d = (int) x; /* 0 <= d < 2^chunk_bits. */
mp_limb_t d = (int) x; /* 0 <= d < 2^chunk_bits. */
x -= d;
if (!(x >= L_(0.0) && x < L_(1.0)))
abort ();
@@ -166,9 +165,8 @@ decode (DOUBLE x, mp_limb_t limbs[NLIMBS1])
{
/* Here we still have MANT_BIT-1*31 bits to extract from x. */
enum { chunk_bits = MIN (31, MAX (MANT_BIT - 1 * 31, 0)) }; /* > 0, <= 31 */
mp_limb_t d;
x *= (mp_limb_t) 1 << chunk_bits;
d = (int) x; /* 0 <= d < 2^chunk_bits. */
mp_limb_t d = (int) x; /* 0 <= d < 2^chunk_bits. */
x -= d;
if (!(x >= L_(0.0) && x < L_(1.0)))
abort ();
@@ -204,9 +202,8 @@ decode (DOUBLE x, mp_limb_t limbs[NLIMBS1])
{
/* Here we still have MANT_BIT-2*31 bits to extract from x. */
enum { chunk_bits = MIN (31, MAX (MANT_BIT - 2 * 31, 0)) }; /* > 0, <= 31 */
mp_limb_t d;
x *= (mp_limb_t) 1 << chunk_bits;
d = (int) x; /* 0 <= d < 2^chunk_bits. */
mp_limb_t d = (int) x; /* 0 <= d < 2^chunk_bits. */
x -= d;
if (!(x >= L_(0.0) && x < L_(1.0)))
abort ();
@@ -242,9 +239,8 @@ decode (DOUBLE x, mp_limb_t limbs[NLIMBS1])
{
/* Here we still have MANT_BIT-3*31 bits to extract from x. */
enum { chunk_bits = MIN (31, MAX (MANT_BIT - 3 * 31, 0)) }; /* > 0, <= 31 */
mp_limb_t d;
x *= (mp_limb_t) 1 << chunk_bits;
d = (int) x; /* 0 <= d < 2^chunk_bits. */
mp_limb_t d = (int) x; /* 0 <= d < 2^chunk_bits. */
x -= d;
if (!(x >= L_(0.0) && x < L_(1.0)))
abort ();
@@ -283,9 +279,8 @@ decode (DOUBLE x, mp_limb_t limbs[NLIMBS1])
for (size_t k = 4; k < chunk_count; k++)
{
size_t chunk_bits = MIN (31, MANT_BIT - k * 31); /* > 0, <= 31 */
mp_limb_t d;
x *= (mp_limb_t) 1 << chunk_bits;
d = (int) x; /* 0 <= d < 2^chunk_bits. */
mp_limb_t d = (int) x; /* 0 <= d < 2^chunk_bits. */
x -= d;
if (!(x >= L_(0.0) && x < L_(1.0)))
abort ();
+12 -23
View File
@@ -45,24 +45,18 @@ orig_fopen (const char *filename, const char *mode)
FILE *
rpl_fopen (const char *filename, const char *mode)
{
int open_direction;
int open_flags;
#if GNULIB_FOPEN_GNU
bool open_flags_gnu;
# define BUF_SIZE 80
char fdopen_mode_buf[BUF_SIZE + 1];
#endif
#if defined _WIN32 && ! defined __CYGWIN__
if (streq (filename, "/dev/null"))
filename = "NUL";
#endif
/* Parse the mode. */
open_direction = 0;
open_flags = 0;
int open_direction = 0;
int open_flags = 0;
#if GNULIB_FOPEN_GNU
open_flags_gnu = false;
bool open_flags_gnu = false;
# define BUF_SIZE 80
char fdopen_mode_buf[BUF_SIZE + 1];
#endif
{
const char *p = mode;
@@ -163,21 +157,18 @@ rpl_fopen (const char *filename, const char *mode)
size_t len = strlen (filename);
if (len > 0 && filename[len - 1] == '/')
{
int fd;
struct stat statbuf;
FILE *fp;
if (open_direction != O_RDONLY)
{
errno = EISDIR;
return NULL;
}
fd = open (filename, open_direction | open_flags,
S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH);
int fd = open (filename, open_direction | open_flags,
S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH);
if (fd < 0)
return NULL;
struct stat statbuf;
if (fstat (fd, &statbuf) >= 0 && !S_ISDIR (statbuf.st_mode))
{
close (fd);
@@ -185,6 +176,7 @@ rpl_fopen (const char *filename, const char *mode)
return NULL;
}
FILE *fp;
# if GNULIB_FOPEN_GNU
fp = fdopen (fd, fdopen_mode_buf);
# else
@@ -204,15 +196,12 @@ rpl_fopen (const char *filename, const char *mode)
#if GNULIB_FOPEN_GNU
if (open_flags_gnu)
{
int fd;
FILE *fp;
fd = open (filename, open_direction | open_flags,
S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH);
int fd = open (filename, open_direction | open_flags,
S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH);
if (fd < 0)
return NULL;
fp = fdopen (fd, fdopen_mode_buf);
FILE *fp = fdopen (fd, fdopen_mode_buf);
if (fp == NULL)
{
int saved_errno = errno;
+3 -2
View File
@@ -43,12 +43,13 @@ int
forkpty (int *amaster, char *name,
const struct termios *termp, const struct winsize *winp)
{
int master, slave, pid;
int master, slave;
if (openpty (&master, &slave, name, termp, winp) == -1)
return -1;
switch (pid = fork ())
int pid = fork ();
switch (pid)
{
case -1:
close (master);
+1 -3
View File
@@ -32,10 +32,8 @@ int
fprintf (FILE *fp, const char *format, ...)
{
va_list args;
off64_t ret;
va_start (args, format);
ret = vfzprintf (fp, format, args);
off64_t ret = vfzprintf (fp, format, args);
va_end (args);
if (TYPE_MAXIMUM (off64_t) > INT_MAX && ret > INT_MAX)
+3 -7
View File
@@ -73,15 +73,12 @@ freadptrinc (FILE *fp, size_t increment)
int
freadseek (FILE *fp, size_t offset)
{
size_t total_buffered;
int fd;
if (offset == 0)
return 0;
/* Seek over the already read and buffered input as quickly as possible,
without doing any system calls. */
total_buffered = freadahead (fp);
size_t total_buffered = freadahead (fp);
/* This loop is usually executed at most twice: once for ungetc buffer (if
present) and once for the main buffer. */
while (total_buffered > 0)
@@ -111,7 +108,7 @@ freadseek (FILE *fp, size_t offset)
}
/* Test whether the stream is seekable or not. */
fd = fileno (fp);
int fd = fileno (fp);
if (fd >= 0 && lseek (fd, 0, SEEK_CUR) >= 0)
{
/* FP refers to a regular file. fseek is most efficient in this case. */
@@ -121,10 +118,9 @@ freadseek (FILE *fp, size_t offset)
{
/* FP is a non-seekable stream, possibly not even referring to a file
descriptor. Read OFFSET bytes explicitly and discard them. */
char buf[4096];
do
{
char buf[4096];
size_t count = (sizeof (buf) < offset ? sizeof (buf) : offset);
if (fread (buf, 1, count, fp) < count)
goto eof;
+1 -2
View File
@@ -68,7 +68,6 @@ freopen_safer (char const *name, char const *mode, FILE *f)
bool protect_in = false;
bool protect_out = false;
bool protect_err = false;
int saved_errno;
switch (fileno (f))
{
@@ -96,7 +95,7 @@ freopen_safer (char const *name, char const *mode, FILE *f)
f = NULL;
else
f = freopen (name, mode, f);
saved_errno = errno;
int saved_errno = errno;
if (protect_err)
close (STDERR_FILENO);
if (protect_out)
+1 -2
View File
@@ -44,7 +44,6 @@ orig_freopen (const char *filename, const char *mode, FILE *stream)
FILE *
rpl_freopen (const char *filename, const char *mode, FILE *stream)
{
FILE *result;
#if defined _WIN32 && ! defined __CYGWIN__
char const *null_device = "NUL";
if (filename && streq (filename, "/dev/null"))
@@ -57,7 +56,7 @@ rpl_freopen (const char *filename, const char *mode, FILE *stream)
errno = 0;
#endif
result = orig_freopen (filename, mode, stream);
FILE *result = orig_freopen (filename, mode, stream);
if (!result)
{
+3 -3
View File
@@ -57,8 +57,6 @@
DOUBLE
FUNC (DOUBLE x, int *expptr)
{
int sign;
int exponent;
DECL_ROUNDING
/* Test for NaN, infinity, and zero. */
@@ -68,7 +66,7 @@ FUNC (DOUBLE x, int *expptr)
return x;
}
sign = 0;
int sign = 0;
if (x < 0)
{
x = - x;
@@ -77,6 +75,8 @@ FUNC (DOUBLE x, int *expptr)
BEGIN_ROUNDING ();
int exponent;
{
/* Since the exponent is an 'int', it fits in 64 bits. Therefore the
loops are executed no more than 64 times. */

Some files were not shown because too many files have changed in this diff Show More