+2025-11-16 Bruno Haible <bruno@clisp.org>
+
+ tests: Use C99 initialization syntax for single-variable 'for' loops.
+ * tests/altstack-util.h (check_alternate_stack_no_overflow): Declare
+ variable of single-variable 'for' loops in the 'for' clause.
+ * tests/atomic-int-gnulib.h (init_atomic_int): Likewise.
+ * tests/atomic-int-isoc.h (init_atomic_int): Likewise.
+ * tests/atomic-int-posix.h (init_atomic_int): Likewise.
+ * tests/bench-crc.c (main): Likewise.
+ * tests/bench-digest.h (main): Likewise.
+ * tests/bench-mbiter.c (do_test, main): Likewise.
+ * tests/bench-mbiterf.c (do_test, main): Likewise.
+ * tests/bench-mbswidth.c (do_test, main): Likewise.
+ * tests/bench-mbuiter.c (do_test, main): Likewise.
+ * tests/bench-mbuiterf.c (do_test, main): Likewise.
+ * tests/bench-mcel.c (noop_test, main): Likewise.
+ * tests/bench-pagealign_alloc.c (allocate_some_pages, main): Likewise.
+ * tests/bench-totalorder.c (do_float_test, do_double_test,
+ do_long_double_test, main): Likewise.
+ * tests/test-access.h (is_administrator): Likewise.
+ * tests/test-aligned-malloc.c (main): Likewise.
+ * tests/test-aligned_alloc.c (main): Likewise.
+ * tests/test-alloca-opt.c (main): Likewise.
+ * tests/test-arcfour.c (main): Likewise.
+ * tests/test-arctwo.c (main): Likewise.
+ * tests/test-argp.c (parse_opt, main): Likewise.
+ * tests/test-argv-iter.c (main): Likewise.
+ * tests/test-array-mergesort.c (main): Likewise.
+ * tests/test-array_list.c (check_equals, main): Likewise.
+ * tests/test-array_map.c (check_equals, main): Likewise.
+ * tests/test-array_omap.c (check_equals, main): Likewise.
+ * tests/test-array_oset.c (check_equals, gl_sortedlist_indexof_atleast,
+ main): Likewise.
+ * tests/test-array_set.c (check_equals, main): Likewise.
+ * tests/test-asyncsafe-linked_list-strong.c (sigint_handler,
+ signal_sending_thread, main): Likewise.
+ * tests/test-asyncsafe-linked_list-weak.c (init_bag_empty, bag_is_empty,
+ bag_is_subset, bag_equals, bag_or, bag_xor, bag_and_not, sigint_handler,
+ signal_sending_thread, main): Likewise.
+ * tests/test-asyncsafe-spin1.c (main): Likewise.
+ * tests/test-asyncsafe-spin2.c (check_accounts, lock_mutator_thread,
+ test_asyncsafe_spin): Likewise.
+ * tests/test-at-init-2.c (init_squares): Likewise.
+ * tests/test-at-init-3.c (init_cubes): Likewise.
+ * tests/test-avltree_list.c (check_equals, main): Likewise.
+ * tests/test-avltree_omap.c (check_equals, main): Likewise.
+ * tests/test-avltree_oset.c (check_equals, main): Likewise.
+ * tests/test-avltreehash_list.c (check_equals, main): Likewise.
+ * tests/test-btoc32.c (main): Likewise.
+ * tests/test-btowc.c (main): Likewise.
+ * tests/test-c-ctype.c (test_agree_with_C_locale, test_all): Likewise.
+ * tests/test-c-strcasestr.c (main): Likewise.
+ * tests/test-c-strstr.c (main): Likewise.
+ * tests/test-c32isalnum.c (main): Likewise.
+ * tests/test-c32isalpha.c (main): Likewise.
+ * tests/test-c32isblank.c (main): Likewise.
+ * tests/test-c32iscntrl.c (main): Likewise.
+ * tests/test-c32isdigit.c (main): Likewise.
+ * tests/test-c32isgraph.c (main): Likewise.
+ * tests/test-c32islower.c (main): Likewise.
+ * tests/test-c32isprint.c (main): Likewise.
+ * tests/test-c32ispunct.c (main): Likewise.
+ * tests/test-c32isspace.c (main): Likewise.
+ * tests/test-c32isupper.c (main): Likewise.
+ * tests/test-c32isxdigit.c (main): Likewise.
+ * tests/test-c32rtomb.c (main): Likewise.
+ * tests/test-c32rtomb-w32.c (test_one_locale, main): Likewise.
+ * tests/test-c32snrtombs.c (main): Likewise.
+ * tests/test-c32srtombs.c (main): Likewise.
+ * tests/test-c32stombs.c (main): Likewise.
+ * tests/test-c32tolower.c (main): Likewise.
+ * tests/test-c32toupper.c (main): Likewise.
+ * tests/test-c32width.c (main): Likewise.
+ * tests/test-call_once2.c (once_contender_thread, test_once): Likewise.
+ * tests/test-carray_list.c (check_equals, main): Likewise.
+ * tests/test-cbrt.h (test_function): Likewise.
+ * tests/test-ceil2.c (main): Likewise.
+ * tests/test-ceilf2.c (main): Likewise.
+ * tests/test-count-leading-zeros.c (TEST_COUNT_LEADING_ZEROS): Likewise.
+ * tests/test-count-one-bits.c (TEST_COUNT_ONE_BITS): Likewise.
+ * tests/test-count-trailing-zeros.c (TEST_COUNT_TRAILING_ZEROS):
+ Likewise.
+ * tests/test-crc.c (main): Likewise.
+ * tests/test-des.c (main, cipher): Likewise.
+ * tests/test-di-set.c (main): Likewise.
+ * tests/test-digest.h (test_digest_on_files): Likewise.
+ * tests/test-dirent-safer.c (main): Likewise.
+ * tests/test-dirname.c (main): Likewise.
+ * tests/test-dprintf-posix2.c (main): Likewise.
+ * tests/test-dup-safer.c (main): Likewise.
+ * tests/test-dup3.c (main): Likewise.
+ * tests/test-dynarray.c (main): Likewise.
+ * tests/test-exec-child.c (main): Likewise.
+ * tests/test-execle-main.c (get_environ_assignment): Likewise.
+ * tests/test-execute-child.c (main): Likewise.
+ * tests/test-execute-main.c (main): Likewise.
+ * tests/test-execute-script.c (main): Likewise.
+ * tests/test-execve-main.c (get_environ_assignment): Likewise.
+ * tests/test-execvpe-main.c (get_environ_assignment): Likewise.
+ * tests/test-exp.h (test_function): Likewise.
+ * tests/test-exp2.h (test_function): Likewise.
+ * tests/test-explicit_bzero.c (test_stack): Likewise.
+ * tests/test-expm1.h (test_function): Likewise.
+ * tests/test-fabs.h (test_function): Likewise.
+ * tests/test-fchdir.c (main): Likewise.
+ * tests/test-fdatasync.c (main): Likewise.
+ * tests/test-fdopen.c (COUNT): Likewise.
+ * tests/test-fenv-except-trapping-1.c (main): Likewise.
+ * tests/test-ffs.c (naive, main): Likewise.
+ * tests/test-ffsl.c (naive, main): Likewise.
+ * tests/test-ffsll.c (naive, main): Likewise.
+ * tests/test-filemode.c (main): Likewise.
+ * tests/test-filenamecat.c (main): Likewise.
+ * tests/test-filevercmp.c (main): Likewise.
+ * tests/test-float-h.c (test_float, test_double, test_long_double):
+ Likewise.
+ * tests/test-floor2.c (main): Likewise.
+ * tests/test-floorf2.c (main): Likewise.
+ * tests/test-fma2.h (test_function): Likewise.
+ * tests/test-fmod.h (test_function): Likewise.
+ * tests/test-fnmatch-w32.c (main): Likewise.
+ * tests/test-fprintf-posix3.c (main): Likewise.
+ * tests/test-fpurge.c (main): Likewise.
+ * tests/test-free.c (N, __has_feature): Likewise.
+ * tests/test-frexp.h (test_function): Likewise.
+ * tests/test-fsync.c (main): Likewise.
+ * tests/test-fts.c (needles, main): Likewise.
+ * tests/test-gc-arcfour.c (main): Likewise.
+ * tests/test-gc-arctwo.c (main): Likewise.
+ * tests/test-gc-des.c (main): Likewise.
+ * tests/test-gc-hmac-md5.c (main): Likewise.
+ * tests/test-gc-hmac-sha1.c (main): Likewise.
+ * tests/test-gc-hmac-sha256.c (main): Likewise.
+ * tests/test-gc-hmac-sha512.c (main): Likewise.
+ * tests/test-gc-md2.c (main): Likewise.
+ * tests/test-gc-md4.c (main): Likewise.
+ * tests/test-gc-md5.c (main): Likewise.
+ * tests/test-gc-pbkdf2.c (main): Likewise.
+ * tests/test-gc-pbkdf2-sha1.c (main): Likewise.
+ * tests/test-gc-rijndael.c (main): Likewise.
+ * tests/test-gc-sha1.c (main): Likewise.
+ * tests/test-gc-sha256.c (main): Likewise.
+ * tests/test-gc-sha512.c (main): Likewise.
+ * tests/test-gc-sm3.c (main): Likewise.
+ * tests/test-getaddrinfo.c (simple): Likewise.
+ * tests/test-getcwd.c (test_long_name): Likewise.
+ * tests/test-getgroups.c (main): Likewise.
+ * tests/test-getlogin_r.c (main): Likewise.
+ * tests/test-getndelim2.c (main): Likewise.
+ * tests/test-getopt.h (test_getopt): Likewise.
+ * tests/test-getopt_long.h (test_getopt_long, test_getopt_long_posix):
+ Likewise.
+ * tests/test-getrusage.c (main): Likewise.
+ * tests/test-getusershell.c (second_pass): Likewise.
+ * tests/test-hash.c (main): Likewise.
+ * tests/test-hash_map.c (check_equals, main): Likewise.
+ * tests/test-hash_set.c (check_equals, string_hashcode, main): Likewise.
+ * tests/test-hmac-md5.c (hmac_check): Likewise.
+ * tests/test-hmac-sha1.c (hmac_check): Likewise.
+ * tests/test-hmac-sha256.c (hmac_check): Likewise.
+ * tests/test-hmac-sha512.c (hmac_check): Likewise.
+ * tests/test-hypot.h (test_function): Likewise.
+ * tests/test-idpriv-drop.c (main): Likewise.
+ * tests/test-idpriv-droptemp.c (main): Likewise.
+ * tests/test-ieee754-h.c (main): Likewise.
+ * tests/test-ilogb.h (test_function): Likewise.
+ * tests/test-ino-map.c (INO_MAP_INIT): Likewise.
+ * tests/test-integer_length.c (naive, main): Likewise.
+ * tests/test-integer_length_l.c (naive, main): Likewise.
+ * tests/test-integer_length_ll.c (naive, main): Likewise.
+ * tests/test-isalnum_l.c (test_single_locale_common): Likewise.
+ * tests/test-isalpha_l.c (test_single_locale_common): Likewise.
+ * tests/test-isblank.c (main): Likewise.
+ * tests/test-isblank_l.c (test_single_locale_common): Likewise.
+ * tests/test-iscntrl_l.c (test_single_locale_common): Likewise.
+ * tests/test-isdigit_l.c (test_single_locale_common): Likewise.
+ * tests/test-isgraph_l.c (test_single_locale_common): Likewise.
+ * tests/test-islower_l.c (test_single_locale_common): Likewise.
+ * tests/test-isprint_l.c (test_single_locale_common): Likewise.
+ * tests/test-ispunct_l.c (test_single_locale_common): Likewise.
+ * tests/test-isspace_l.c (test_single_locale_common): Likewise.
+ * tests/test-isupper_l.c (test_single_locale_common): Likewise.
+ * tests/test-iswdigit.c (main): Likewise.
+ * tests/test-iswpunct.c (main): Likewise.
+ * tests/test-iswxdigit.c (main): Likewise.
+ * tests/test-isxdigit_l.c (test_single_locale_common): Likewise.
+ * tests/test-ldexp.h (test_function): Likewise.
+ * tests/test-ldexp-ieee.h (test_function): Likewise.
+ * tests/test-libtextstyle.c (main): Likewise.
+ * tests/test-linkat.c (main): Likewise.
+ * tests/test-linked_list.c (check_equals, main): Likewise.
+ * tests/test-linkedhash_list.c (check_equals, main): Likewise.
+ * tests/test-linkedhash_map.c (check_equals, main): Likewise.
+ * tests/test-linkedhash_set.c (check_equals, string_hashcode, main):
+ Likewise.
+ * tests/test-localename.c (test_locale_name, test_locale_name_thread):
+ Likewise.
+ * tests/test-lock.c (check_accounts, gl_lock_define_initialized,
+ test_lock, gl_rwlock_define_initialized, test_rwlock,
+ reclock_mutator_thread, test_recursive_lock, once_contender_thread,
+ test_once): Likewise.
+ * tests/test-log.h (test_function): Likewise.
+ * tests/test-log10.h (test_function): Likewise.
+ * tests/test-log1p.h (test_function): Likewise.
+ * tests/test-log2.h (test_function): Likewise.
+ * tests/test-logb.h (test_function): Likewise.
+ * tests/test-login_tty.c (main): Likewise.
+ * tests/test-malloca.c (main): Likewise.
+ * tests/test-mbrlen.c (main): Likewise.
+ * tests/test-mbrlen-w32.c (test_one_locale, main): Likewise.
+ * tests/test-mbrtoc16.c (main): Likewise.
+ * tests/test-mbrtoc16-w32.c (test_one_locale, main): Likewise.
+ * tests/test-mbrtoc32.c (main): Likewise.
+ * tests/test-mbrtoc32-w32.c (test_one_locale, main): Likewise.
+ * tests/test-mbrtowc.c (main): Likewise.
+ * tests/test-mbrtowc-w32.c (test_one_locale, main): Likewise.
+ * tests/test-mbsnrtoc32s.c (main): Likewise.
+ * tests/test-mbsnrtowcs.c (main): Likewise.
+ * tests/test-mbsrtoc32s.c (main): Likewise.
+ * tests/test-mbsrtowcs.c (main): Likewise.
+ * tests/test-mbstoc32s.c (main): Likewise.
+ * tests/test-mbstowcs.c (main): Likewise.
+ * tests/test-md2-buffer.c (main): Likewise.
+ * tests/test-md4-buffer.c (main): Likewise.
+ * tests/test-md5-buffer.c (main): Likewise.
+ * tests/test-memalign.c (main): Likewise.
+ * tests/test-memcasecmp.c (main): Likewise.
+ * tests/test-memchr.c (main): Likewise.
+ * tests/test-memchr2.c (main): Likewise.
+ * tests/test-memcmp.c (main): Likewise.
+ * tests/test-memmem.c (main): Likewise.
+ * tests/test-memrchr.c (main): Likewise.
+ * tests/test-memset_explicit.c (test_stack): Likewise.
+ * tests/test-mkfifoat.c (main): Likewise.
+ * tests/test-modf.h (test_function): Likewise.
+ * tests/test-mountlist.c (main): Likewise.
+ * tests/test-mtx.c (check_accounts, lock_mutator_thread, test_mtx_plain,
+ reclock_mutator_thread, test_mtx_recursive): Likewise.
+ * tests/test-nl_langinfo2.c (main): Likewise.
+ * tests/test-nonblocking-misc.h (init_data): Likewise.
+ * tests/test-nstrftime.h (posixtm_test, tzalloc_test, quarter_test):
+ Likewise.
+ * tests/test-obstack-printf.h (test_function): Likewise.
+ * tests/test-obstack-zprintf-big.c (main): Likewise.
+ * tests/test-obstack-zprintf-posix.c (RESULT_EQ): Likewise.
+ * tests/test-open.h (test_open): Likewise.
+ * tests/test-openat-safer.c (main): Likewise.
+ * tests/test-options.c (test_getopt_long, test_getopt_long_posix):
+ Likewise.
+ * tests/test-pagealign_alloc.c (main): Likewise.
+ * tests/test-parse-datetime.c (main): Likewise.
+ * tests/test-perror2.c (main): Likewise.
+ * tests/test-pipe-filter-gi1.c (done_read): Likewise.
+ * tests/test-pipe-filter-ii1.c (done_read): Likewise.
+ * tests/test-pipe2.c (main): Likewise.
+ * tests/test-popen.h (main): Likewise.
+ * tests/test-posix_memalign.c (main): Likewise.
+ * tests/test-posix_spawn-script.c (main): Likewise.
+ * tests/test-posix_spawnp-script.c (main): Likewise.
+ * tests/test-posixtm.c (main): Likewise.
+ * tests/test-pread.c (main): Likewise.
+ * tests/test-pthread-mutex.c (check_accounts, lock_mutator_thread,
+ test_pthread_mutex_normal, reclock_mutator_thread,
+ test_pthread_mutex_recursive): Likewise.
+ * tests/test-pthread-once2.c (once_contender_thread, test_once):
+ Likewise.
+ * tests/test-pthread-rwlock.c (check_accounts, rwlock_mutator_thread,
+ test_rwlock): Likewise.
+ * tests/test-pthread-spin.c (check_accounts, lock_mutator_thread,
+ test_pthread_spin): Likewise.
+ * tests/test-pthread-tss.c (worker_thread, test_tss, dtorcheck1_thread,
+ test_tss_dtorcheck1, dtorcheck2_thread, test_tss_dtorcheck2,
+ racecheck_thread, test_tss_racecheck): Likewise.
+ * tests/test-ptsname.c (main): Likewise.
+ * tests/test-ptsname_r.c (test_errors, main): Likewise.
+ * tests/test-pwrite.c (main): Likewise.
+ * tests/test-quotearg-simple.c (main): Likewise.
+ * tests/test-random.c (main): Likewise.
+ * tests/test-random-mt.c (random_invocator_thread, main): Likewise.
+ * tests/test-random_r.c (test_failed, main): Likewise.
+ * tests/test-rawmemchr.c (main): Likewise.
+ * tests/test-rbtree_list.c (check_equals, main): Likewise.
+ * tests/test-rbtree_omap.c (check_equals, main): Likewise.
+ * tests/test-rbtree_oset.c (check_equals, main): Likewise.
+ * tests/test-rbtreehash_list.c (check_equals, main): Likewise.
+ * tests/test-readlink.h (test_readlink): Likewise.
+ * tests/test-readutmp.c (main): Likewise.
+ * tests/test-remainder.h (test_function): Likewise.
+ * tests/test-renameat.c (main): Likewise.
+ * tests/test-renameatu.c (main): Likewise.
+ * tests/test-rijndael.c (main): Likewise.
+ * tests/test-rint.h (test_function): Likewise.
+ * tests/test-round2.c (main): Likewise.
+ * tests/test-sameacls.c (main, room): Likewise.
+ * tests/test-scratch-buffer.c (main): Likewise.
+ * tests/test-sethostname2.c (main): Likewise.
+ * tests/test-sh-quote.c (main): Likewise.
+ * tests/test-sha1-buffer.c (main): Likewise.
+ * tests/test-sha224-buffer.c (main): Likewise.
+ * tests/test-sha256-buffer.c (main): Likewise.
+ * tests/test-sha3-224-buffer.c (check): Likewise.
+ * tests/test-sha3-256-buffer.c (check): Likewise.
+ * tests/test-sha3-384-buffer.c (check): Likewise.
+ * tests/test-sha3-512-buffer.c (check): Likewise.
+ * tests/test-sha384-buffer.c (main): Likewise.
+ * tests/test-sha512-buffer.c (main): Likewise.
+ * tests/test-simple-atomic.c (int_mutator_thread, ptr_mutator_thread,
+ main): Likewise.
+ * tests/test-sm3-buffer.c (test, main): Likewise.
+ * tests/test-snprintf.c (main): Likewise.
+ * tests/test-snprintf-posix.h (test_function, value, word): Likewise.
+ * tests/test-snzprintf-posix.h (test_function): Likewise.
+ * tests/test-spawn-pipe-child.c (main): Likewise.
+ * tests/test-spawn-pipe-main.c (main): Likewise.
+ * tests/test-spawn-pipe-script.c (main): Likewise.
+ * tests/test-spin1.c (gl_spinlock_define_initialized): Likewise.
+ * tests/test-spin2.c (check_accounts, gl_spinlock_define,
+ test_asyncsafe_spin): Likewise.
+ * tests/test-sprintf-posix.h (value, word): Likewise.
+ * tests/test-sqrt.h (test_function): Likewise.
+ * tests/test-ssfmalloc.c (main): Likewise.
+ * tests/test-stat-time.c (prepare_test, test_mtime, test_birthtime):
+ Likewise.
+ * tests/test-stpncpy.c (main): Likewise.
+ * tests/test-strcasestr.c (main): Likewise.
+ * tests/test-strchrnul.c (main): Likewise.
+ * tests/test-strerror_r.c (main): Likewise.
+ * tests/test-striconveh.c (main): Likewise.
+ * tests/test-striconveha.c (main): Likewise.
+ * tests/test-strnlen.c (main): Likewise.
+ * tests/test-strstr.c (main): Likewise.
+ * tests/test-system-quote-main.c (check_all, main): Likewise.
+ * tests/test-szprintf-posix.h (test_function): Likewise.
+ * tests/test-thread_local.c (worker_thread, test_thread_local):
+ Likewise.
+ * tests/test-times.c (main): Likewise.
+ * tests/test-timespec.c (main): Likewise.
+ * tests/test-tls.c (worker_thread, test_tls, dtorcheck1_thread,
+ test_tls_dtorcheck1, dtorcheck2_thread, test_tls_dtorcheck2,
+ racecheck_thread, test_tls_racecheck): Likewise.
+ * tests/test-tolower_l.c (test_single_locale_common): Likewise.
+ * tests/test-toupper_l.c (test_single_locale_common): Likewise.
+ * tests/test-trunc2.c (main): Likewise.
+ * tests/test-truncf2.c (main): Likewise.
+ * tests/test-tsearch.c (memfry, walk_tree, mangle_tree, main): Likewise.
+ * tests/test-tss.c (worker_thread, test_tss, dtorcheck1_thread,
+ test_tss_dtorcheck1, dtorcheck2_thread, test_tss_dtorcheck2,
+ racecheck_thread, test_tss_racecheck): Likewise.
+ * tests/test-userspec.c (main): Likewise.
+ * tests/test-vasnprintf.c (test_function): Likewise.
+ * tests/test-vasnprintf-big.c (main): Likewise.
+ * tests/test-vasnprintf-posix.c (test_function, value, word): Likewise.
+ * tests/test-vasnwprintf.c (test_function): Likewise.
+ * tests/test-vasnwprintf-big.c (main): Likewise.
+ * tests/test-vasnwprintf-posix.c (test_function, value, word): Likewise.
+ * tests/test-vasprintf.c (test_vasprintf, test_asprintf): Likewise.
+ * tests/test-vasprintf-posix.c (test_function, value, word): Likewise.
+ * tests/test-vaszprintf-posix.c (test_function): Likewise.
+ * tests/test-vsnprintf.c (main): Likewise.
+ * tests/test-wcrtomb.c (main): Likewise.
+ * tests/test-wcrtomb-w32.c (test_one_locale, main): Likewise.
+ * tests/test-wcsnrtombs.c (main): Likewise.
+ * tests/test-wcsrtombs.c (main): Likewise.
+ * tests/test-wcwidth.c (main): Likewise.
+ * tests/test-xstrtol.c (main): Likewise.
+ * tests/test-xvasprintf.c (test_xvasprintf, test_xasprintf): Likewise.
+ * tests/unicase/test-mapping-part2.h (main): Likewise.
+ * tests/unicase/test-predicate-part2.h (main): Likewise.
+ * tests/uniconv/test-u8-conv-from-enc.c (main): Likewise.
+ * tests/uniconv/test-u8-conv-to-enc.c (main): Likewise.
+ * tests/uniconv/test-u8-strconv-from-enc.c (main): Likewise.
+ * tests/uniconv/test-u8-strconv-to-enc.c (main): Likewise.
+ * tests/uniconv/test-u16-conv-from-enc.c (main): Likewise.
+ * tests/uniconv/test-u16-conv-to-enc.c (main): Likewise.
+ * tests/uniconv/test-u16-strconv-from-enc.c (main): Likewise.
+ * tests/uniconv/test-u16-strconv-to-enc.c (main): Likewise.
+ * tests/uniconv/test-u32-conv-from-enc.c (main): Likewise.
+ * tests/uniconv/test-u32-conv-to-enc.c (main): Likewise.
+ * tests/uniconv/test-u32-strconv-from-enc.c (main): Likewise.
+ * tests/uniconv/test-u32-strconv-to-enc.c (main): Likewise.
+ * tests/unictype/test-bidi_test.c (main): Likewise.
+ * tests/unictype/test-block_list.c (main): Likewise.
+ * tests/unictype/test-block_of.c (main): Likewise.
+ * tests/unictype/test-categ_byname.c (main): Likewise.
+ * tests/unictype/test-categ_none.c (main): Likewise.
+ * tests/unictype/test-categ_of.c (main): Likewise.
+ * tests/unictype/test-decdigit.c (main): Likewise.
+ * tests/unictype/test-digit.c (main): Likewise.
+ * tests/unictype/test-incb_of.c (main): Likewise.
+ * tests/unictype/test-joininggroup_of.c (main): Likewise.
+ * tests/unictype/test-joiningtype_of.c (main): Likewise.
+ * tests/unictype/test-numeric.c (main): Likewise.
+ * tests/unictype/test-pr_byname.c (main): Likewise.
+ * tests/unictype/test-pr_test.c (main): Likewise.
+ * tests/unictype/test-predicate-part2.h (main): Likewise.
+ * tests/unictype/test-scripts.c (main): Likewise.
+ * tests/unigbrk/test-u8-grapheme-breaks.c (test_u8_grapheme_breaks):
+ Likewise.
+ * tests/unigbrk/test-u8-grapheme-next.c (test_u8_grapheme_next):
+ Likewise.
+ * tests/unigbrk/test-u8-grapheme-prev.c (test_u8_grapheme_prev):
+ Likewise.
+ * tests/unigbrk/test-u16-grapheme-breaks.c (test_u16_grapheme_breaks):
+ Likewise.
+ * tests/unigbrk/test-u16-grapheme-next.c (test_u16_grapheme_next):
+ Likewise.
+ * tests/unigbrk/test-u16-grapheme-prev.c (test_u16_grapheme_prev):
+ Likewise.
+ * tests/unigbrk/test-u32-grapheme-breaks.c (test_u32_grapheme_breaks):
+ Likewise.
+ * tests/unigbrk/test-u32-grapheme-next.c (test_u32_grapheme_next):
+ Likewise.
+ * tests/unigbrk/test-u32-grapheme-prev.c (test_u32_grapheme_prev):
+ Likewise.
+ * tests/unigbrk/test-uc-gbrk-prop.c (main): Likewise.
+ * tests/unigbrk/test-uc-grapheme-breaks.c (test_uc_grapheme_breaks):
+ Likewise.
+ * tests/unigbrk/test-ulc-grapheme-breaks.c (sizeof): Likewise.
+ * tests/unilbrk/test-u8-possible-linebreaks.c (test_function): Likewise.
+ * tests/unilbrk/test-u8-width-linebreaks.c (test_function): Likewise.
+ * tests/unilbrk/test-u16-possible-linebreaks.c (test_function):
+ Likewise.
+ * tests/unilbrk/test-u16-width-linebreaks.c (test_function): Likewise.
+ * tests/unilbrk/test-u32-possible-linebreaks.c (test_function):
+ Likewise.
+ * tests/unilbrk/test-u32-width-linebreaks.c (test_function): Likewise.
+ * tests/unilbrk/test-uc-possible-linebreaks.c (main): Likewise.
+ * tests/unilbrk/test-ulc-possible-linebreaks.c (test_function):
+ Likewise.
+ * tests/unilbrk/test-ulc-width-linebreaks.c (test_function): Likewise.
+ * tests/uniname/test-uninames.c (name_has_alias, test_name_lookup,
+ test_inverse_lookup, test_alias_lookup, main): Likewise.
+ * tests/uninorm/test-u8-nfc.c (test_u8_nfc): Likewise.
+ * tests/uninorm/test-u8-nfd.c (test_u8_nfd): Likewise.
+ * tests/uninorm/test-u8-nfkc.c (test_u8_nfkc): Likewise.
+ * tests/uninorm/test-u8-nfkd.c (test_u8_nfkd): Likewise.
+ * tests/uninorm/test-u16-nfc.c (test_u16_nfc): Likewise.
+ * tests/uninorm/test-u16-nfd.c (test_u16_nfd): Likewise.
+ * tests/uninorm/test-u16-nfkc.c (test_u16_nfkc): Likewise.
+ * tests/uninorm/test-u16-nfkd.c (test_u16_nfkd): Likewise.
+ * tests/uninorm/test-u32-nfc.c (test_u32_nfc): Likewise.
+ * tests/uninorm/test-u32-nfd.c (test_u32_nfd): Likewise.
+ * tests/uninorm/test-u32-nfkc.c (test_u32_nfkc): Likewise.
+ * tests/uninorm/test-u32-nfkd.c (test_u32_nfkd): Likewise.
+ * tests/uninorm/test-u32-normalize-big.c (read_normalization_test_file,
+ test_specific, test_other, free_normalization_test_file): Likewise.
+ * tests/uninorm/test-uninorm-filter-nfc.c (check): Likewise.
+ * tests/unistdio/test-u8-asnprintf-big.c (main): Likewise.
+ * tests/unistdio/test-u8-asnprintf1.h (test_function): Likewise.
+ * tests/unistdio/test-u16-asnprintf1.h (test_function): Likewise.
+ * tests/unistdio/test-u32-asnprintf1.h (test_function): Likewise.
+ * tests/unistdio/test-ulc-asnprintf-big.c (main): Likewise.
+ * tests/unistdio/test-ulc-asnprintf1.h (test_function): Likewise.
+ * tests/unistr/test-chr.h (main): Likewise.
+ * tests/unistr/test-cmp.h (test_cmp): Likewise.
+ * tests/unistr/test-cpy-alloc.h (main): Likewise.
+ * tests/unistr/test-cpy.h (main): Likewise.
+ * tests/unistr/test-move.h (main): Likewise.
+ * tests/unistr/test-pcpy.h (main): Likewise.
+ * tests/unistr/test-set.h (NMAX, main): Likewise.
+ * tests/unistr/test-stpcpy.h (main): Likewise.
+ * tests/unistr/test-stpncpy.h (check_single, check): Likewise.
+ * tests/unistr/test-strcat.h (main): Likewise.
+ * tests/unistr/test-strchr.h (test_strchr): Likewise.
+ * tests/unistr/test-strcpy.h (main): Likewise.
+ * tests/unistr/test-strdup.h (main): Likewise.
+ * tests/unistr/test-strncat.h (check_single, check): Likewise.
+ * tests/unistr/test-strncpy.h (check_single, check): Likewise.
+ * tests/unistr/test-strnlen.h (check): Likewise.
+ * tests/unistr/test-u-strstr.h (test_u_strstr): Likewise.
+ * tests/unistr/test-u16-mblen.c (main): Likewise.
+ * tests/unistr/test-u16-mbsnlen.c (main): Likewise.
+ * tests/unistr/test-u16-mbtouc.h (test_function): Likewise.
+ * tests/unistr/test-u16-mbtoucr.c (main): Likewise.
+ * tests/unistr/test-u16-next.c (main): Likewise.
+ * tests/unistr/test-u16-prev.c (check, check_invalid, main): Likewise.
+ * tests/unistr/test-u16-strmblen.c (main): Likewise.
+ * tests/unistr/test-u16-strmbtouc.c (main): Likewise.
+ * tests/unistr/test-u16-uctomb.c (main): Likewise.
+ * tests/unistr/test-u32-mblen.c (main): Likewise.
+ * tests/unistr/test-u32-mbsnlen.c (main): Likewise.
+ * tests/unistr/test-u32-mbtouc.h (test_function): Likewise.
+ * tests/unistr/test-u32-mbtoucr.c (main): Likewise.
+ * tests/unistr/test-u32-next.c (main): Likewise.
+ * tests/unistr/test-u32-prev.c (check, check_invalid, main): Likewise.
+ * tests/unistr/test-u32-strmblen.c (main): Likewise.
+ * tests/unistr/test-u32-strmbtouc.c (main): Likewise.
+ * tests/unistr/test-u32-uctomb.c (main): Likewise.
+ * tests/unistr/test-u8-mblen.c (main): Likewise.
+ * tests/unistr/test-u8-mbsnlen.c (main): Likewise.
+ * tests/unistr/test-u8-mbtouc.c (test_safe_function): Likewise.
+ * tests/unistr/test-u8-mbtouc.h (test_function): Likewise.
+ * tests/unistr/test-u8-mbtoucr.c (main): Likewise.
+ * tests/unistr/test-u8-next.c (main): Likewise.
+ * tests/unistr/test-u8-prev.c (check, check_invalid, main): Likewise.
+ * tests/unistr/test-u8-strmblen.c (main): Likewise.
+ * tests/unistr/test-u8-strmbtouc.c (main): Likewise.
+ * tests/unistr/test-u8-uctomb.c (main): Likewise.
+ * tests/uniwbrk/test-u8-wordbreaks.c (main): Likewise.
+ * tests/uniwbrk/test-u16-wordbreaks.c (main): Likewise.
+ * tests/uniwbrk/test-u32-wordbreaks.c (main): Likewise.
+ * tests/uniwbrk/test-uc-wordbreaks.c (main): Likewise.
+ * tests/uniwbrk/test-ulc-wordbreaks.c (main): Likewise.
+ * tests/uniwidth/test-uc_width.c (main): Likewise.
+ * tests/uniwidth/test-uc_width2.c (main): Likewise.
+ * tests/virtualbox.h (is_running_under_virtualbox_kvm, num_cpus):
+ Likewise.
+ * tests/test-regex.c (bug_regex11, main): Likewise. Rename local
+ variables.
+
2025-11-15 Paul Eggert <eggert@cs.ucla.edu>
-Wunused-const-variable started in GCC 6.1 not 4.4
static void
check_alternate_stack_no_overflow (void)
{
- unsigned int i;
-
- for (i = MYSTACK_CRUMPLE_ZONE; i > 0; i--)
+ for (unsigned int i = MYSTACK_CRUMPLE_ZONE; i > 0; i--)
if (*(mystack - i) != 's')
{
printf ("Alternate stack was exceeded by %u bytes!!\n", i);
exit (1);
}
- for (i = MYSTACK_CRUMPLE_ZONE; i > 0; i--)
+ for (unsigned int i = MYSTACK_CRUMPLE_ZONE; i > 0; i--)
if (*(mystack + MYSTACK_SIZE - 1 + i) != 's')
{
printf ("Alternate stack was exceeded by %u bytes!!\n", i);
init_atomic_int (struct atomic_int *ai)
{
sem_t *s;
- unsigned int count;
- for (count = 0; ; count++)
+ for (unsigned int count = 0; ; count++)
{
char name[80];
/* Use getpid() in the name, so that different processes running at the
init_atomic_int (struct atomic_int *ai)
{
sem_t *s;
- unsigned int count;
- for (count = 0; ; count++)
+ for (unsigned int count = 0; ; count++)
{
char name[80];
/* Use getpid() in the name, so that different processes running at the
init_atomic_int (struct atomic_int *ai)
{
sem_t *s;
- unsigned int count;
- for (count = 0; ; count++)
+ for (unsigned int count = 0; ; count++)
{
char name[80];
/* Use getpid() in the name, so that different processes running at the
struct timings_state ts;
timing_start (&ts);
- int count;
- for (count = 0; count < repeat; count++)
+ for (int count = 0; count < repeat; count++)
{
uint32_t volatile digest = crc32 (randomb, sizeof randomb);
ASSERT (digest == 0x5299f9d2U);
}
/* Fill the memory block. */
- {
- size_t i;
- for (i = 0; i < size; i++)
- memblock[i] =
- (unsigned char) (((i * (i-1) * (i-5)) >> 6) + (i % 499) + (i % 101));
- }
+ for (size_t i = 0; i < size; i++)
+ memblock[i] =
+ (unsigned char) (((i * (i-1) * (i-5)) >> 6) + (i % 499) + (i % 101));
struct timings_state ts;
timing_start (&ts);
- int count;
- for (count = 0; count < repeat; count++)
+ for (int count = 0; count < repeat; count++)
{
char digest[64];
FUNC (memblock, size, digest);
timing_start (&ts);
size_t text_len = strlen (text);
- int count;
- for (count = 0; count < repeat; count++)
+ for (int count = 0; count < repeat; count++)
{
unsigned long long sum = 0;
mbi_iterator_t iter;
text_init ();
/* Execute each test. */
- size_t i;
- for (i = 0; i < strlen (tests); i++)
+ for (size_t i = 0; i < strlen (tests); i++)
{
char test = tests[i];
timing_start (&ts);
size_t text_len = strlen (text);
- int count;
- for (count = 0; count < repeat; count++)
+ for (int count = 0; count < repeat; count++)
{
unsigned long long sum = 0;
const char *text_end = text + text_len;
text_init ();
/* Execute each test. */
- size_t i;
- for (i = 0; i < strlen (tests); i++)
+ for (size_t i = 0; i < strlen (tests); i++)
{
char test = tests[i];
struct timings_state ts;
timing_start (&ts);
- int count;
- for (count = 0; count < repeat; count++)
+ for (int count = 0; count < repeat; count++)
{
mbswidth (text, 0);
}
text_init ();
/* Execute each test. */
- size_t i;
- for (i = 0; i < strlen (tests); i++)
+ for (size_t i = 0; i < strlen (tests); i++)
{
char test = tests[i];
struct timings_state ts;
timing_start (&ts);
- int count;
- for (count = 0; count < repeat; count++)
+ for (int count = 0; count < repeat; count++)
{
unsigned long long sum = 0;
mbui_iterator_t iter;
text_init ();
/* Execute each test. */
- size_t i;
- for (i = 0; i < strlen (tests); i++)
+ for (size_t i = 0; i < strlen (tests); i++)
{
char test = tests[i];
struct timings_state ts;
timing_start (&ts);
- int count;
- for (count = 0; count < repeat; count++)
+ for (int count = 0; count < repeat; count++)
{
unsigned long long sum = 0;
mbuif_state_t state;
text_init ();
/* Execute each test. */
- size_t i;
- for (i = 0; i < strlen (tests); i++)
+ for (size_t i = 0; i < strlen (tests); i++)
{
char test = tests[i];
for (int count = 0; count < repeat; count++)
{
- char const *iter;
- for (iter = text; iter < text_end; iter++)
+ for (char const *iter = text; iter < text_end; iter++)
sum += (uintptr_t) iter;
}
text_init ();
/* Execute each test. */
- size_t i;
- for (i = 0; i < strlen (tests); i++)
+ for (size_t i = 0; i < strlen (tests); i++)
{
char test = tests[i];
static int
allocate_some_pages (void)
{
- int i;
-
- for (i = 1; i <= 9; i++)
+ for (int i = 1; i <= 9; i++)
if (pagealign_alloc (pagesize) == NULL)
return -1;
- for (i = 1; i <= 2; i++)
+ for (int i = 1; i <= 2; i++)
if (pagealign_alloc (2 * pagesize) == NULL)
return -1;
- for (i = 1; i <= 1; i++)
+ for (int i = 1; i <= 1; i++)
if (pagealign_alloc (3 * pagesize) == NULL)
return -1;
pagesize = getpagesize ();
/* Execute each test. */
- size_t i;
- for (i = 0; i < strlen (tests); i++)
+ for (size_t i = 0; i < strlen (tests); i++)
{
char test = tests[i];
struct timings_state ts;
timing_start (&ts);
- int count;
- for (count = 0; count < repeat; count++)
+ for (int count = 0; count < repeat; count++)
{
for (int i = 0; i < n; i++)
for (int j = 0; j < n; j++)
struct timings_state ts;
timing_start (&ts);
- int count;
- for (count = 0; count < repeat; count++)
+ for (int count = 0; count < repeat; count++)
{
for (int i = 0; i < n; i++)
for (int j = 0; j < n; j++)
struct timings_state ts;
timing_start (&ts);
- int count;
- for (count = 0; count < repeat; count++)
+ for (int count = 0; count < repeat; count++)
{
for (int i = 0; i < n; i++)
for (int j = 0; j < n; j++)
int repeat = atoi (argv[2]);
/* Execute each test. */
- size_t i;
- for (i = 0; i < strlen (tests); i++)
+ for (size_t i = 0; i < strlen (tests); i++)
{
char test = tests[i];
is_administrator (void)
{
gid_t list[100];
- int i;
int count = getgroups (sizeof (list) / sizeof (list[0]), list);
if (count < 0)
return 0;
- for (i = 0; i < count; i++)
+ for (int i = 0; i < count; i++)
{
gid_t id = list[i];
struct group *details = getgrgid (id);
void *aligned8_blocks[SIZEOF (sizes)];
void *aligned16_blocks[SIZEOF (sizes)];
void *aligned32_blocks[SIZEOF (sizes)];
- size_t i;
- for (i = 0; i < SIZEOF (sizes); i++)
+ for (size_t i = 0; i < SIZEOF (sizes); i++)
{
size_t size = sizes[i];
memset (aligned32_blocks[i], 'z', size);
}
- for (i = 0; i < SIZEOF (sizes); i++)
+ for (size_t i = 0; i < SIZEOF (sizes); i++)
{
aligned4_free (aligned4_blocks[i]);
aligned8_free (aligned8_blocks[i]);
void *aligned16_blocks[SIZEOF (sizes)];
void *aligned32_blocks[SIZEOF (sizes)];
void *aligned64_blocks[SIZEOF (sizes)];
- size_t i;
- for (i = 0; i < SIZEOF (sizes); i++)
+ for (size_t i = 0; i < SIZEOF (sizes); i++)
{
size_t size = sizes[i];
memset (aligned64_blocks[i], 'z', size);
}
- for (i = 0; i < SIZEOF (sizes); i++)
+ for (size_t i = 0; i < SIZEOF (sizes); i++)
{
free (aligned2_blocks[i]);
free (aligned4_blocks[i]);
main ()
{
#if HAVE_ALLOCA
- int i;
-
/* Repeat a lot of times, to make sure there's no memory leak. */
- for (i = 0; i < 100000; i++)
+ for (int i = 0; i < 100000; i++)
{
/* Try various values.
n = 0 gave a crash on Alpha with gcc-2.5.8.
arcfour_stream (&ctx, plaintext_1, scratch, sizeof (plaintext_1));
if (memcmp (scratch, ciphertext_1, sizeof (ciphertext_1)))
{
- size_t i;
printf ("expected:\n");
- for (i = 0; i < 5; i++)
+ for (size_t i = 0; i < 5; i++)
printf ("%02x ", scratch[i] & 0xFF);
printf ("\ncomputed:\n");
- for (i = 0; i < 5; i++)
+ for (size_t i = 0; i < 5; i++)
printf ("%02x ", ciphertext_1[i] & 0xFF);
printf ("\n");
return 1;
arcfour_stream (&ctx, scratch, scratch, sizeof (plaintext_1));
if (memcmp (scratch, plaintext_1, sizeof (plaintext_1)))
{
- size_t i;
printf ("expected:\n");
- for (i = 0; i < 5; i++)
+ for (size_t i = 0; i < 5; i++)
printf ("%02x ", plaintext_1[i] & 0xFF);
printf ("\ncomputed:\n");
- for (i = 0; i < 5; i++)
+ for (size_t i = 0; i < 5; i++)
printf ("%02x ", scratch[i] & 0xFF);
printf ("\n");
return 1;
if (memcmp (scratch, ciphertext_4, sizeof (ciphertext_4)))
{
- size_t i;
printf ("expected:\n");
- for (i = 0; i < sizeof (ciphertext_4); i++)
+ for (size_t i = 0; i < sizeof (ciphertext_4); i++)
printf ("%02x ", ciphertext_4[i] & 0xFF);
printf ("\ncomputed:\n");
- for (i = 0; i < sizeof (ciphertext_4); i++)
+ for (size_t i = 0; i < sizeof (ciphertext_4); i++)
printf ("%02x ", scratch[i] & 0xFF);
printf ("\n");
return 1;
if (memcmp (scratch, ciphertext_5, sizeof (ciphertext_5)))
{
- size_t i;
printf ("expected:\n");
- for (i = 0; i < sizeof (ciphertext_5); i++)
+ for (size_t i = 0; i < sizeof (ciphertext_5); i++)
printf ("%02x ", ciphertext_5[i] & 0xFF);
printf ("\ncomputed:\n");
- for (i = 0; i < sizeof (ciphertext_5); i++)
+ for (size_t i = 0; i < sizeof (ciphertext_5); i++)
printf ("%02x ", scratch[i] & 0xFF);
printf ("\n");
return 1;
if (memcmp (scratch, ciphertext_6, sizeof (ciphertext_6)))
{
- size_t i;
printf ("expected:\n");
- for (i = 0; i < sizeof (ciphertext_6); i++)
+ for (size_t i = 0; i < sizeof (ciphertext_6); i++)
printf ("%02x ", ciphertext_6[i] & 0xFF);
printf ("\ncomputed:\n");
- for (i = 0; i < sizeof (ciphertext_6); i++)
+ for (size_t i = 0; i < sizeof (ciphertext_6); i++)
printf ("%02x ", scratch[i] & 0xFF);
printf ("\n");
return 1;
parse_opt (int key, char *arg, struct argp_state *state)
{
struct test_args *args = state->input;
- int i;
switch (key)
{
case ARGP_KEY_INIT:
- for (i = 0; state->root_argp->children[i].argp; i++)
+ for (int i = 0; state->root_argp->children[i].argp; i++)
state->child_inputs[i] = args;
break;
main (int argc, char **argv)
{
struct argp_child argp_children[3], group1_children[2], group2_children[2];
- test_fp *fun;
group1_children[0] = group1_1_child;
group1_children[1].argp = NULL;
return argp_parse (&test_argp, argc, argv, 0, NULL, &test_args);
}
- for (fun = test_fun; *fun; fun++)
+ for (test_fp *fun = test_fun; *fun; fun++)
(*fun) (&test_argp);
if (failure_count)
{one, two, three, NULL}
};
- int use_stream;
- for (use_stream = 0; use_stream < 2; use_stream++)
+ for (int use_stream = 0; use_stream < 2; use_stream++)
{
- size_t i;
- for (i = 0; i < ARRAY_CARDINALITY (av); i++)
+ for (size_t i = 0; i < ARRAY_CARDINALITY (av); i++)
{
FILE *fp;
struct argv_iterator *ai;
int
main ()
{
- size_t n;
-
/* Test merge_sort_fromto. */
- for (n = 1; n <= NMAX; n++)
+ for (size_t n = 1; n <= NMAX; n++)
{
struct foo *dst;
struct foo *tmp;
double *qsort_result;
- size_t i;
dst = (struct foo *) malloc ((n + 1) * sizeof (struct foo));
dst[n].x = 0x4A6A71FE; /* canary */
/* Verify the result. */
qsort_result = (double *) malloc (n * sizeof (double));
- for (i = 0; i < n; i++)
+ for (size_t i = 0; i < n; i++)
qsort_result[i] = data[i].x;
qsort (qsort_result, n, sizeof (double), cmp_double);
- for (i = 0; i < n; i++)
+ for (size_t i = 0; i < n; i++)
ASSERT (dst[i].x == qsort_result[i]);
/* Verify the stability. */
- for (i = 0; i < n; i++)
+ for (size_t i = 0; i < n; i++)
if (i > 0 && dst[i - 1].x == dst[i].x)
ASSERT (dst[i - 1].index < dst[i].index);
}
/* Test merge_sort_inplace. */
- for (n = 1; n <= NMAX; n++)
+ for (size_t n = 1; n <= NMAX; n++)
{
struct foo *src;
struct foo *tmp;
double *qsort_result;
- size_t i;
src = (struct foo *) malloc ((n + 1) * sizeof (struct foo));
src[n].x = 0x4A6A71FE; /* canary */
tmp = (struct foo *) malloc ((n + 1) * sizeof (struct foo));
tmp[n].x = 0x587EF149; /* canary */
- for (i = 0; i < n; i++)
+ for (size_t i = 0; i < n; i++)
src[i] = data[i];
merge_sort_inplace (src, n, tmp);
/* Verify the result. */
qsort_result = (double *) malloc (n * sizeof (double));
- for (i = 0; i < n; i++)
+ for (size_t i = 0; i < n; i++)
qsort_result[i] = data[i].x;
qsort (qsort_result, n, sizeof (double), cmp_double);
- for (i = 0; i < n; i++)
+ for (size_t i = 0; i < n; i++)
ASSERT (src[i].x == qsort_result[i]);
/* Verify the stability. */
- for (i = 0; i < n; i++)
+ for (size_t i = 0; i < n; i++)
if (i > 0 && src[i - 1].x == src[i].x)
ASSERT (src[i - 1].index < src[i].index);
static void
check_equals (gl_list_t list1, gl_list_t list2)
{
- size_t n, i;
+ size_t n;
n = gl_list_size (list1);
ASSERT (n == gl_list_size (list2));
- for (i = 0; i < n; i++)
+ for (size_t i = 0; i < n; i++)
{
ASSERT (gl_list_get_at (list1, i) == gl_list_get_at (list2, i));
}
size_t initial_size = RANDOM (50);
const void **contents =
(const void **) malloc (initial_size * sizeof (const void *));
- size_t i;
- unsigned int repeat;
- for (i = 0; i < initial_size; i++)
+ for (size_t i = 0; i < initial_size; i++)
contents[i] = RANDOM_OBJECT ();
/* Create list1. */
/* Create list2. */
list2 = gl_list_nx_create_empty (GL_ARRAY_LIST, NULL, NULL, NULL, true);
ASSERT (list2 != NULL);
- for (i = 0; i < initial_size; i++)
+ for (size_t i = 0; i < initial_size; i++)
ASSERT (gl_list_nx_add_last (list2, contents[i]) != NULL);
check_equals (list1, list2);
check_equals_by_forward_iteration (list1, list2);
check_equals_by_backward_iteration (list1, list2);
- for (repeat = 0; repeat < 10000; repeat++)
+ for (unsigned int repeat = 0; repeat < 10000; repeat++)
{
unsigned int operation = RANDOM (18);
switch (operation)
const void *elt;
iter1 = gl_list_iterator (list1);
iter2 = gl_list_iterator (list2);
- for (i = 0; i < n; i++)
+ for (size_t i = 0; i < n; i++)
{
ASSERT (gl_list_iterator_next (&iter1, &elt, NULL));
ASSERT (gl_list_get_at (list1, i) == elt);
const void *elt;
iter1 = gl_list_iterator_from_to (list1, start, end);
iter2 = gl_list_iterator_from_to (list2, start, end);
- for (i = start; i < end; i++)
+ for (size_t i = start; i < end; i++)
{
ASSERT (gl_list_iterator_next (&iter1, &elt, NULL));
ASSERT (gl_list_get_at (list1, i) == elt);
gl_map_iterator_t iter1;
const void *key1;
const void *value1;
- size_t i;
ASSERT (gl_list_size (keys) == n);
ASSERT (gl_list_size (values) == n);
iter1 = gl_map_iterator (map1);
- for (i = 0; i < n; i++)
+ for (size_t i = 0; i < n; i++)
{
ASSERT (gl_map_iterator_next (&iter1, &key1, &value1));
pairs_of_map1[i].key = key1;
if (n > 0)
qsort (pairs_of_map1, n, sizeof (struct pair), cmp_pairs_in_array);
- for (i = 0; i < n; i++)
+ for (size_t i = 0; i < n; i++)
{
ASSERT (pairs_of_map1[i].key == gl_list_get_at (keys, i));
ASSERT (pairs_of_map1[i].value == gl_list_get_at (values, i));
{
size_t initial_size = RANDOM (20);
- size_t i;
- unsigned int repeat;
/* Create map1. */
map1 = gl_map_nx_create_empty (GL_ARRAY_MAP,
check_all (map1, keys, values);
/* Initialize them. */
- for (i = 0; i < initial_size; i++)
+ for (size_t i = 0; i < initial_size; i++)
{
const char *key = RANDOM_OBJECT ();
const char *value = RANDOM_OBJECT ();
check_all (map1, keys, values);
}
- for (repeat = 0; repeat < 100000; repeat++)
+ for (unsigned int repeat = 0; repeat < 100000; repeat++)
{
unsigned int operation = RANDOM (3);
switch (operation)
const void *key2;
const void *value2;
gl_list_node_t node;
- size_t i;
iter1 = gl_omap_iterator (map1);
iterk = gl_list_iterator (keys);
iterv = gl_list_iterator (values);
- for (i = 0; i < n; i++)
+ for (size_t i = 0; i < n; i++)
{
ASSERT (gl_omap_iterator_next (&iter1, &key1, &value1));
ASSERT (gl_list_iterator_next (&iterk, &key2, &node));
{
size_t initial_size = RANDOM (20);
- size_t i;
- unsigned int repeat;
/* Create map1. */
map1 = gl_omap_nx_create_empty (GL_ARRAY_OMAP, (gl_mapkey_compar_fn) strcmp, NULL, NULL);
check_all (map1, keys, values);
/* Initialize them. */
- for (i = 0; i < initial_size; i++)
+ for (size_t i = 0; i < initial_size; i++)
{
const char *key = RANDOM_OBJECT ();
const char *value = RANDOM_OBJECT ();
check_all (map1, keys, values);
}
- for (repeat = 0; repeat < 100000; repeat++)
+ for (unsigned int repeat = 0; repeat < 100000; repeat++)
{
unsigned int operation = RANDOM (3);
switch (operation)
const void *elt1;
const void *elt2;
gl_list_node_t node2;
- size_t i;
iter1 = gl_oset_iterator (set1);
iter2 = gl_list_iterator (set2);
- for (i = 0; i < n; i++)
+ for (size_t i = 0; i < n; i++)
{
ASSERT (gl_oset_iterator_next (&iter1, &elt1));
ASSERT (gl_list_iterator_next (&iter2, &elt2, &node2));
{
/* This implementation is slow, but easy to verify. */
size_t count = gl_list_size (set);
- size_t index;
- for (index = 0; index < count; index++)
+ for (size_t index = 0; index < count; index++)
if (threshold_fn (gl_list_get_at (set, index), threshold))
return index;
return (size_t)(-1);
{
size_t initial_size = RANDOM (20);
- size_t i;
- unsigned int repeat;
/* Create set1. */
set1 = gl_oset_nx_create_empty (GL_ARRAY_OSET, (gl_setelement_compar_fn) strcmp, NULL);
check_all (set1, set2);
/* Initialize them. */
- for (i = 0; i < initial_size; i++)
+ for (size_t i = 0; i < initial_size; i++)
{
const char *obj = RANDOM_OBJECT ();
ASSERT (gl_oset_nx_add (set1, obj)
check_all (set1, set2);
}
- for (repeat = 0; repeat < 100000; repeat++)
+ for (unsigned int repeat = 0; repeat < 100000; repeat++)
{
unsigned int operation = RANDOM (4);
switch (operation)
gl_oset_iterator_t iter2;
const void *elt1;
const void *elt2;
- size_t i;
iter1 = gl_set_iterator (set1);
iter2 = gl_oset_iterator (set2);
- for (i = 0; i < n; i++)
+ for (size_t i = 0; i < n; i++)
{
ASSERT (gl_set_iterator_next (&iter1, &elt1));
ASSERT (gl_oset_iterator_next (&iter2, &elt2));
qsort (elements_of_set1, n, sizeof (const void *), cmp_objects_in_array);
qsort (elements_of_set2, n, sizeof (const void *), cmp_objects_in_array);
}
- for (i = 0; i < n; i++)
+ for (size_t i = 0; i < n; i++)
ASSERT (elements_of_set1[i] == elements_of_set2[i]);
free (elements_of_set2);
free (elements_of_set1);
{
size_t initial_size = RANDOM (20);
- size_t i;
- unsigned int repeat;
/* Create set1. */
set1 = gl_set_nx_create_empty (GL_ARRAY_SET, NULL, NULL, NULL);
check_all (set1, set2);
/* Initialize them. */
- for (i = 0; i < initial_size; i++)
+ for (size_t i = 0; i < initial_size; i++)
{
const char *obj = RANDOM_OBJECT ();
ASSERT (gl_set_nx_add (set1, obj) == gl_oset_add (set2, obj));
check_all (set1, set2);
}
- for (repeat = 0; repeat < 100000; repeat++)
+ for (unsigned int repeat = 0; repeat < 100000; repeat++)
{
unsigned int operation = RANDOM (3);
switch (operation)
thread. By the time we get here, the mutator thread can have done
any number of mutations; it is reasonable to assume that this number
of mutations is small. */
- size_t i;
- for (i = recent_sums_newest_index - 1;;)
+ for (size_t i = recent_sums_newest_index - 1;;)
{
if (sum == recent_sums[i % NUM_RECENT_SUMS]
&& i >= recent_sums_oldest_index)
if (test != 3)
block_sigint ();
- int repeat;
-
- for (repeat = 1000; repeat > 0; repeat--)
+ for (int repeat = 1000; repeat > 0; repeat--)
{
num_signals_sent++; send_signal ();
num_signals_sent++; send_signal ();
size_t initial_size = RANDOM (50);
const void **contents =
(const void **) malloc (initial_size * sizeof (const void *));
- size_t i;
- for (i = 0; i < initial_size; i++)
+ for (size_t i = 0; i < initial_size; i++)
contents[i] = RANDOM_OBJECT ();
list1 = gl_list_nx_create_empty (GL_LINKED_LIST, NULL, NULL, NULL, true);
ASSERT (list1 != NULL);
- for (i = 0; i < initial_size; i++)
+ for (size_t i = 0; i < initial_size; i++)
ASSERT (gl_list_nx_add_first (list1, contents[i]) != NULL);
list2 = gl_list_nx_create_empty (GL_LINKED_LIST, NULL, NULL, NULL, true);
ASSERT (list2 != NULL);
- for (i = 0; i < initial_size; i++)
+ for (size_t i = 0; i < initial_size; i++)
ASSERT (gl_list_nx_add_last (list2, contents[i]) != NULL);
uintptr_t initial_sum = 0;
- for (i = 0; i < initial_size; i++)
+ for (size_t i = 0; i < initial_size; i++)
initial_sum += (uintptr_t) contents[i];
recent_sums_oldest_index = 0;
recent_sums[0] = initial_sum;
static void
init_bag_empty (bag_t *bagp)
{
- size_t i;
-
- for (i = 0; i < BAG_SIZE / 32; i++)
+ for (size_t i = 0; i < BAG_SIZE / 32; i++)
bagp->bits[i] = 0;
}
_GL_ATTRIBUTE_MAYBE_UNUSED static bool
bag_is_empty (bag_t bag)
{
- size_t i;
-
- for (i = 0; i < BAG_SIZE / 32; i++)
+ for (size_t i = 0; i < BAG_SIZE / 32; i++)
if (bag.bits[i] != 0)
return false;
return true;
static bool
bag_is_subset (bag_t bag1, bag_t bag2)
{
- size_t i;
-
- for (i = 0; i < BAG_SIZE / 32; i++)
+ for (size_t i = 0; i < BAG_SIZE / 32; i++)
if ((bag1.bits[i] & ~bag2.bits[i]) != 0)
return false;
return true;
static bool
bag_equals (bag_t bag1, bag_t bag2)
{
- size_t i;
-
- for (i = 0; i < BAG_SIZE / 32; i++)
+ for (size_t i = 0; i < BAG_SIZE / 32; i++)
if (bag1.bits[i] != bag2.bits[i])
return false;
return true;
bag_or (bag_t bag1, bag_t bag2)
{
bag_t bag;
- size_t i;
- for (i = 0; i < BAG_SIZE / 32; i++)
+ for (size_t i = 0; i < BAG_SIZE / 32; i++)
bag.bits[i] = bag1.bits[i] | bag2.bits[i];
return bag;
bag_xor (bag_t bag1, bag_t bag2)
{
bag_t bag;
- size_t i;
- for (i = 0; i < BAG_SIZE / 32; i++)
+ for (size_t i = 0; i < BAG_SIZE / 32; i++)
bag.bits[i] = bag1.bits[i] ^ bag2.bits[i];
return bag;
bag_and_not (bag_t bag1, bag_t bag2)
{
bag_t bag;
- size_t i;
- for (i = 0; i < BAG_SIZE / 32; i++)
+ for (size_t i = 0; i < BAG_SIZE / 32; i++)
bag.bits[i] = bag1.bits[i] & ~bag2.bits[i];
return bag;
thread. By the time we get here, the mutator thread can have done
any number of mutations; it is reasonable to assume that this number
of mutations is small. */
- size_t i;
bag_t changes_from_i_to_newest;
init_bag_empty (&changes_from_i_to_newest);
- for (i = recent_newest_index;;)
+ for (size_t i = recent_newest_index;;)
{
if (bag_is_subset (bag_xor (bag, recent_bags[i % NUM_RECENT_BAGS]),
changes_from_i_to_newest)
if (test != 3)
block_sigint ();
- int repeat;
-
- for (repeat = 1000; repeat > 0; repeat--)
+ for (int repeat = 1000; repeat > 0; repeat--)
{
num_signals_sent++; send_signal ();
num_signals_sent++; send_signal ();
size_t initial_size = RANDOM (50);
const void **contents =
(const void **) malloc (initial_size * sizeof (const void *));
- size_t i;
- for (i = 0; i < initial_size; i++)
+ for (size_t i = 0; i < initial_size; i++)
contents[i] = RANDOM_OBJECT ();
list1 = gl_list_nx_create_empty (GL_LINKED_LIST, NULL, NULL, NULL, true);
ASSERT (list1 != NULL);
- for (i = 0; i < initial_size; i++)
+ for (size_t i = 0; i < initial_size; i++)
ASSERT (gl_list_nx_add_first (list1, contents[i]) != NULL);
list2 = gl_list_nx_create_empty (GL_LINKED_LIST, NULL, NULL, NULL, true);
ASSERT (list2 != NULL);
- for (i = 0; i < initial_size; i++)
+ for (size_t i = 0; i < initial_size; i++)
ASSERT (gl_list_nx_add_last (list2, contents[i]) != NULL);
recent_oldest_index = 0;
/* Check a spin-lock initialized through asyncsafe_spin_init. */
{
asyncsafe_spinlock_t local_spin_lock;
- int i;
asyncsafe_spin_init (&local_spin_lock);
- for (i = 0; i < 10; i++)
+ for (int i = 0; i < 10; i++)
{
sigset_t saved_set;
asyncsafe_spin_lock (&local_spin_lock, false, &set, &saved_set);
static void
check_accounts (void)
{
- int i, sum;
+ int sum;
sum = 0;
- for (i = 0; i < ACCOUNT_COUNT; i++)
+ for (int i = 0; i < ACCOUNT_COUNT; i++)
sum += account[i];
if (sum != ACCOUNT_COUNT * 1000)
abort ();
static void *
lock_mutator_thread (void *arg)
{
- int repeat;
-
- for (repeat = REPEAT_COUNT; repeat > 0; repeat--)
+ for (int repeat = REPEAT_COUNT; repeat > 0; repeat--)
{
sigset_t saved_signals;
int i1, i2, value;
static void
test_asyncsafe_spin (void)
{
- int i;
gl_thread_t checkerthread;
gl_thread_t threads[THREAD_COUNT];
/* Initialization. */
- for (i = 0; i < ACCOUNT_COUNT; i++)
+ for (int i = 0; i < ACCOUNT_COUNT; i++)
account[i] = 1000;
init_atomic_int (&lock_checker_done);
set_atomic_int_value (&lock_checker_done, 0);
/* Spawn the threads. */
checkerthread = gl_thread_create (lock_checker_thread, NULL);
- for (i = 0; i < THREAD_COUNT; i++)
+ for (int i = 0; i < THREAD_COUNT; i++)
threads[i] = gl_thread_create (lock_mutator_thread, NULL);
/* Wait for the threads to terminate. */
- for (i = 0; i < THREAD_COUNT; i++)
+ for (int i = 0; i < THREAD_COUNT; i++)
gl_thread_join (threads[i], NULL);
set_atomic_int_value (&lock_checker_done, 1);
gl_thread_join (checkerthread, NULL);
static void
init_squares (void)
{
- int i;
-
sum_of_squares = 0;
- for (i = 0; i <= 100; i++)
+ for (int i = 0; i <= 100; i++)
sum_of_squares += i * i;
}
static void
init_cubes (void)
{
- int i;
-
sum_of_cubes = 0;
- for (i = 0; i <= 100; i++)
+ for (int i = 0; i <= 100; i++)
sum_of_cubes += i * i *i;
}
static void
check_equals (gl_list_t list1, gl_list_t list2)
{
- size_t n, i;
+ size_t n;
n = gl_list_size (list1);
ASSERT (n == gl_list_size (list2));
- for (i = 0; i < n; i++)
+ for (size_t i = 0; i < n; i++)
{
ASSERT (gl_list_get_at (list1, i) == gl_list_get_at (list2, i));
}
size_t initial_size = RANDOM (50);
const void **contents =
(const void **) malloc (initial_size * sizeof (const void *));
- size_t i;
- unsigned int repeat;
- for (i = 0; i < initial_size; i++)
+ for (size_t i = 0; i < initial_size; i++)
contents[i] = RANDOM_OBJECT ();
/* Create list1. */
/* Create list2. */
list2 = gl_list_nx_create_empty (GL_AVLTREE_LIST, NULL, NULL, NULL, true);
ASSERT (list2 != NULL);
- for (i = 0; i < initial_size; i++)
+ for (size_t i = 0; i < initial_size; i++)
ASSERT (gl_list_nx_add_last (list2, contents[i]) != NULL);
/* Create list3. */
check_equals_by_forward_iteration (list1, list2);
check_equals_by_backward_iteration (list1, list2);
- for (repeat = 0; repeat < 10000; repeat++)
+ for (unsigned int repeat = 0; repeat < 10000; repeat++)
{
unsigned int operation = RANDOM (18);
switch (operation)
iter1 = gl_list_iterator (list1);
iter2 = gl_list_iterator (list2);
iter3 = gl_list_iterator (list3);
- for (i = 0; i < n; i++)
+ for (size_t i = 0; i < n; i++)
{
ASSERT (gl_list_iterator_next (&iter1, &elt, NULL));
ASSERT (gl_list_get_at (list1, i) == elt);
iter1 = gl_list_iterator_from_to (list1, start, end);
iter2 = gl_list_iterator_from_to (list2, start, end);
iter3 = gl_list_iterator_from_to (list3, start, end);
- for (i = start; i < end; i++)
+ for (size_t i = start; i < end; i++)
{
ASSERT (gl_list_iterator_next (&iter1, &elt, NULL));
ASSERT (gl_list_get_at (list1, i) == elt);
const void *value1;
const void *key2;
const void *value2;
- size_t i;
iter1 = gl_omap_iterator (map1);
iter2 = gl_omap_iterator (map2);
- for (i = 0; i < n; i++)
+ for (size_t i = 0; i < n; i++)
{
ASSERT (gl_omap_iterator_next (&iter1, &key1, &value1));
ASSERT (gl_omap_iterator_next (&iter2, &key2, &value2));
{
size_t initial_size = RANDOM (20);
- size_t i;
- unsigned int repeat;
/* Create map1. */
map1 = gl_omap_nx_create_empty (GL_ARRAY_OMAP, (gl_mapkey_compar_fn) strcmp, NULL, NULL);
check_all (map1, map2);
/* Initialize them. */
- for (i = 0; i < initial_size; i++)
+ for (size_t i = 0; i < initial_size; i++)
{
const char *key = RANDOM_OBJECT ();
const char *value = RANDOM_OBJECT ();
check_all (map1, map2);
}
- for (repeat = 0; repeat < 100000; repeat++)
+ for (unsigned int repeat = 0; repeat < 100000; repeat++)
{
unsigned int operation = RANDOM (3);
switch (operation)
gl_oset_iterator_t iter1, iter2;
const void *elt1;
const void *elt2;
- size_t i;
iter1 = gl_oset_iterator (set1);
iter2 = gl_oset_iterator (set2);
- for (i = 0; i < n; i++)
+ for (size_t i = 0; i < n; i++)
{
ASSERT (gl_oset_iterator_next (&iter1, &elt1));
ASSERT (gl_oset_iterator_next (&iter2, &elt2));
{
size_t initial_size = RANDOM (20);
- size_t i;
- unsigned int repeat;
/* Create set1. */
set1 = gl_oset_nx_create_empty (GL_ARRAY_OSET, (gl_setelement_compar_fn) strcmp, NULL);
check_all (set1, set2);
/* Initialize them. */
- for (i = 0; i < initial_size; i++)
+ for (size_t i = 0; i < initial_size; i++)
{
const char *obj = RANDOM_OBJECT ();
ASSERT (gl_oset_nx_add (set1, obj) == gl_oset_nx_add (set2, obj));
check_all (set1, set2);
}
- for (repeat = 0; repeat < 100000; repeat++)
+ for (unsigned int repeat = 0; repeat < 100000; repeat++)
{
unsigned int operation = RANDOM (4);
switch (operation)
static void
check_equals (gl_list_t list1, gl_list_t list2)
{
- size_t n, i;
+ size_t n;
n = gl_list_size (list1);
ASSERT (n == gl_list_size (list2));
- for (i = 0; i < n; i++)
+ for (size_t i = 0; i < n; i++)
{
ASSERT (gl_list_get_at (list1, i) == gl_list_get_at (list2, i));
}
size_t initial_size = RANDOM (50);
const void **contents =
(const void **) malloc (initial_size * sizeof (const void *));
- size_t i;
- unsigned int repeat;
- for (i = 0; i < initial_size; i++)
+ for (size_t i = 0; i < initial_size; i++)
contents[i] = RANDOM_OBJECT ();
/* Create list1. */
list2 = gl_list_nx_create_empty (GL_AVLTREEHASH_LIST,
string_equals, string_hash, NULL, true);
ASSERT (list2 != NULL);
- for (i = 0; i < initial_size; i++)
+ for (size_t i = 0; i < initial_size; i++)
ASSERT (gl_list_nx_add_last (list2, contents[i]) != NULL);
/* Create list3. */
check_equals_by_forward_iteration (list1, list2);
check_equals_by_backward_iteration (list1, list2);
- for (repeat = 0; repeat < 10000; repeat++)
+ for (unsigned int repeat = 0; repeat < 10000; repeat++)
{
unsigned int operation = RANDOM (18);
switch (operation)
iter1 = gl_list_iterator (list1);
iter2 = gl_list_iterator (list2);
iter3 = gl_list_iterator (list3);
- for (i = 0; i < n; i++)
+ for (size_t i = 0; i < n; i++)
{
ASSERT (gl_list_iterator_next (&iter1, &elt, NULL));
ASSERT (gl_list_get_at (list1, i) == elt);
iter1 = gl_list_iterator_from_to (list1, start, end);
iter2 = gl_list_iterator_from_to (list2, start, end);
iter3 = gl_list_iterator_from_to (list3, start, end);
- for (i = start; i < end; i++)
+ for (size_t i = start; i < end; i++)
{
ASSERT (gl_list_iterator_next (&iter1, &elt, NULL));
ASSERT (gl_list_get_at (list1, i) == elt);
int
main (int argc, char *argv[])
{
- int c;
-
/* configure should already have checked that the locale is supported. */
if (setlocale (LC_ALL, "") == NULL)
return 1;
{
case '1':
/* C or POSIX locale. */
- for (c = 0; c < 0x100; c++)
+ for (int c = 0; c < 0x100; c++)
if (c != 0)
{
/* We are testing all nonnull bytes. */
case '2':
/* Locale encoding is ISO-8859-1 or ISO-8859-15. */
- for (c = 0; c < 0x80; c++)
+ for (int c = 0; c < 0x80; c++)
ASSERT (btoc32 (c) == c);
- for (c = 0xA0; c < 0x100; c++)
+ for (int c = 0xA0; c < 0x100; c++)
ASSERT (btoc32 (c) != WEOF);
return test_exit_status;
case '3':
/* Locale encoding is UTF-8. */
- for (c = 0; c < 0x80; c++)
+ for (int c = 0; c < 0x80; c++)
ASSERT (btoc32 (c) == c);
- for (c = 0x80; c < 0x100; c++)
+ for (int c = 0x80; c < 0x100; c++)
ASSERT (btoc32 (c) == WEOF);
return test_exit_status;
}
int
main (int argc, char *argv[])
{
- int c;
-
/* configure should already have checked that the locale is supported. */
if (setlocale (LC_ALL, "") == NULL)
return 1;
{
case '1':
/* C or POSIX locale. */
- for (c = 0; c < 0x100; c++)
+ for (int c = 0; c < 0x100; c++)
if (c != 0)
{
/* We are testing all nonnull bytes. */
case '2':
/* Locale encoding is ISO-8859-1 or ISO-8859-15. */
- for (c = 0; c < 0x80; c++)
+ for (int c = 0; c < 0x80; c++)
ASSERT (btowc (c) == c);
- for (c = 0xA0; c < 0x100; c++)
+ for (int c = 0xA0; c < 0x100; c++)
ASSERT (btowc (c) != WEOF);
return test_exit_status;
case '3':
/* Locale encoding is UTF-8. */
- for (c = 0; c < 0x80; c++)
+ for (int c = 0; c < 0x80; c++)
ASSERT (btowc (c) == c);
- for (c = 0x80; c < 0x100; c++)
+ for (int c = 0x80; c < 0x100; c++)
ASSERT (btowc (c) == WEOF);
return test_exit_status;
}
static void
test_agree_with_C_locale (void)
{
- int c;
-
- for (c = 0; c <= UCHAR_MAX; c++)
+ for (int c = 0; c <= UCHAR_MAX; c++)
{
if (c_isascii (c))
{
static void
test_all (void)
{
- int c;
int n_isascii = 0;
- for (c = CHAR_MIN; c <= UCHAR_MAX; c++)
+ for (int c = CHAR_MIN; c <= UCHAR_MAX; c++)
{
if (! (0 <= c && c <= CHAR_MAX))
{
"with_multilib_list\n";
size_t h_len = strlen (h);
char *haystack = malloc (h_len + 1);
- size_t i;
ASSERT (haystack);
- for (i = 0; i < h_len - strlen (needle); i++)
+ for (size_t i = 0; i < h_len - strlen (needle); i++)
{
const char *p;
memcpy (haystack, h, h_len + 1);
"with_multilib_list\n";
size_t h_len = strlen (h);
char *haystack = malloc (h_len + 1);
- size_t i;
ASSERT (haystack);
- for (i = 0; i < h_len - strlen (needle); i++)
+ for (size_t i = 0; i < h_len - strlen (needle); i++)
{
const char *p;
memcpy (haystack, h, h_len + 1);
- in the "POSIX" locale (which is usually the same as the "C" locale),
the alphanumeric characters include only the ASCII A ... Z and a ... z
and 0 ... 9 characters. */
- {
- int c;
-
- for (c = 0; c < 0x100; c++)
- switch (c)
- {
- case '\t': case '\v': case '\f':
- case ' ': case '!': case '"': case '#': case '%':
- case '&': case '\'': case '(': case ')': case '*':
- case '+': case ',': case '-': case '.': case '/':
- case '0': case '1': case '2': case '3': case '4':
- case '5': case '6': case '7': case '8': case '9':
- case ':': case ';': case '<': case '=': case '>':
- case '?':
- case 'A': case 'B': case 'C': case 'D': case 'E':
- case 'F': case 'G': case 'H': case 'I': case 'J':
- case 'K': case 'L': case 'M': case 'N': case 'O':
- case 'P': case 'Q': case 'R': case 'S': case 'T':
- case 'U': case 'V': case 'W': case 'X': case 'Y':
- case 'Z':
- case '[': case '\\': case ']': case '^': case '_':
- case 'a': case 'b': case 'c': case 'd': case 'e':
- case 'f': case 'g': case 'h': case 'i': case 'j':
- case 'k': case 'l': case 'm': case 'n': case 'o':
- case 'p': case 'q': case 'r': case 's': case 't':
- case 'u': case 'v': case 'w': case 'x': case 'y':
- case 'z': case '{': case '|': case '}': case '~':
- /* c is in the ISO C "basic character set". */
- buf[0] = (unsigned char) c;
- is = for_character (buf, 1);
- switch (c)
- {
- case '0': case '1': case '2': case '3': case '4':
- case '5': case '6': case '7': case '8': case '9':
- case 'A': case 'B': case 'C': case 'D': case 'E':
- case 'F': case 'G': case 'H': case 'I': case 'J':
- case 'K': case 'L': case 'M': case 'N': case 'O':
- case 'P': case 'Q': case 'R': case 'S': case 'T':
- case 'U': case 'V': case 'W': case 'X': case 'Y':
- case 'Z':
- case 'a': case 'b': case 'c': case 'd': case 'e':
- case 'f': case 'g': case 'h': case 'i': case 'j':
- case 'k': case 'l': case 'm': case 'n': case 'o':
- case 'p': case 'q': case 'r': case 's': case 't':
- case 'u': case 'v': case 'w': case 'x': case 'y':
- case 'z':
- ASSERT (is != 0);
- break;
- default:
- ASSERT (is == 0);
- break;
- }
- break;
- }
- }
+ for (int c = 0; c < 0x100; c++)
+ switch (c)
+ {
+ case '\t': case '\v': case '\f':
+ case ' ': case '!': case '"': case '#': case '%':
+ case '&': case '\'': case '(': case ')': case '*':
+ case '+': case ',': case '-': case '.': case '/':
+ case '0': case '1': case '2': case '3': case '4':
+ case '5': case '6': case '7': case '8': case '9':
+ case ':': case ';': case '<': case '=': case '>':
+ case '?':
+ case 'A': case 'B': case 'C': case 'D': case 'E':
+ case 'F': case 'G': case 'H': case 'I': case 'J':
+ case 'K': case 'L': case 'M': case 'N': case 'O':
+ case 'P': case 'Q': case 'R': case 'S': case 'T':
+ case 'U': case 'V': case 'W': case 'X': case 'Y':
+ case 'Z':
+ case '[': case '\\': case ']': case '^': case '_':
+ case 'a': case 'b': case 'c': case 'd': case 'e':
+ case 'f': case 'g': case 'h': case 'i': case 'j':
+ case 'k': case 'l': case 'm': case 'n': case 'o':
+ case 'p': case 'q': case 'r': case 's': case 't':
+ case 'u': case 'v': case 'w': case 'x': case 'y':
+ case 'z': case '{': case '|': case '}': case '~':
+ /* c is in the ISO C "basic character set". */
+ buf[0] = (unsigned char) c;
+ is = for_character (buf, 1);
+ switch (c)
+ {
+ case '0': case '1': case '2': case '3': case '4':
+ case '5': case '6': case '7': case '8': case '9':
+ case 'A': case 'B': case 'C': case 'D': case 'E':
+ case 'F': case 'G': case 'H': case 'I': case 'J':
+ case 'K': case 'L': case 'M': case 'N': case 'O':
+ case 'P': case 'Q': case 'R': case 'S': case 'T':
+ case 'U': case 'V': case 'W': case 'X': case 'Y':
+ case 'Z':
+ case 'a': case 'b': case 'c': case 'd': case 'e':
+ case 'f': case 'g': case 'h': case 'i': case 'j':
+ case 'k': case 'l': case 'm': case 'n': case 'o':
+ case 'p': case 'q': case 'r': case 's': case 't':
+ case 'u': case 'v': case 'w': case 'x': case 'y':
+ case 'z':
+ ASSERT (is != 0);
+ break;
+ default:
+ ASSERT (is == 0);
+ break;
+ }
+ break;
+ }
if (argc > 1)
switch (argv[1][0])
- in the "POSIX" locale (which is usually the same as the "C" locale),
the alphabetic characters include only the ASCII A ... Z and a ... z
characters. */
- {
- int c;
-
- for (c = 0; c < 0x100; c++)
- switch (c)
- {
- case '\t': case '\v': case '\f':
- case ' ': case '!': case '"': case '#': case '%':
- case '&': case '\'': case '(': case ')': case '*':
- case '+': case ',': case '-': case '.': case '/':
- case '0': case '1': case '2': case '3': case '4':
- case '5': case '6': case '7': case '8': case '9':
- case ':': case ';': case '<': case '=': case '>':
- case '?':
- case 'A': case 'B': case 'C': case 'D': case 'E':
- case 'F': case 'G': case 'H': case 'I': case 'J':
- case 'K': case 'L': case 'M': case 'N': case 'O':
- case 'P': case 'Q': case 'R': case 'S': case 'T':
- case 'U': case 'V': case 'W': case 'X': case 'Y':
- case 'Z':
- case '[': case '\\': case ']': case '^': case '_':
- case 'a': case 'b': case 'c': case 'd': case 'e':
- case 'f': case 'g': case 'h': case 'i': case 'j':
- case 'k': case 'l': case 'm': case 'n': case 'o':
- case 'p': case 'q': case 'r': case 's': case 't':
- case 'u': case 'v': case 'w': case 'x': case 'y':
- case 'z': case '{': case '|': case '}': case '~':
- /* c is in the ISO C "basic character set". */
- buf[0] = (unsigned char) c;
- is = for_character (buf, 1);
- switch (c)
- {
- case 'A': case 'B': case 'C': case 'D': case 'E':
- case 'F': case 'G': case 'H': case 'I': case 'J':
- case 'K': case 'L': case 'M': case 'N': case 'O':
- case 'P': case 'Q': case 'R': case 'S': case 'T':
- case 'U': case 'V': case 'W': case 'X': case 'Y':
- case 'Z':
- case 'a': case 'b': case 'c': case 'd': case 'e':
- case 'f': case 'g': case 'h': case 'i': case 'j':
- case 'k': case 'l': case 'm': case 'n': case 'o':
- case 'p': case 'q': case 'r': case 's': case 't':
- case 'u': case 'v': case 'w': case 'x': case 'y':
- case 'z':
- ASSERT (is != 0);
- break;
- default:
- ASSERT (is == 0);
- break;
- }
- break;
- }
- }
+ for (int c = 0; c < 0x100; c++)
+ switch (c)
+ {
+ case '\t': case '\v': case '\f':
+ case ' ': case '!': case '"': case '#': case '%':
+ case '&': case '\'': case '(': case ')': case '*':
+ case '+': case ',': case '-': case '.': case '/':
+ case '0': case '1': case '2': case '3': case '4':
+ case '5': case '6': case '7': case '8': case '9':
+ case ':': case ';': case '<': case '=': case '>':
+ case '?':
+ case 'A': case 'B': case 'C': case 'D': case 'E':
+ case 'F': case 'G': case 'H': case 'I': case 'J':
+ case 'K': case 'L': case 'M': case 'N': case 'O':
+ case 'P': case 'Q': case 'R': case 'S': case 'T':
+ case 'U': case 'V': case 'W': case 'X': case 'Y':
+ case 'Z':
+ case '[': case '\\': case ']': case '^': case '_':
+ case 'a': case 'b': case 'c': case 'd': case 'e':
+ case 'f': case 'g': case 'h': case 'i': case 'j':
+ case 'k': case 'l': case 'm': case 'n': case 'o':
+ case 'p': case 'q': case 'r': case 's': case 't':
+ case 'u': case 'v': case 'w': case 'x': case 'y':
+ case 'z': case '{': case '|': case '}': case '~':
+ /* c is in the ISO C "basic character set". */
+ buf[0] = (unsigned char) c;
+ is = for_character (buf, 1);
+ switch (c)
+ {
+ case 'A': case 'B': case 'C': case 'D': case 'E':
+ case 'F': case 'G': case 'H': case 'I': case 'J':
+ case 'K': case 'L': case 'M': case 'N': case 'O':
+ case 'P': case 'Q': case 'R': case 'S': case 'T':
+ case 'U': case 'V': case 'W': case 'X': case 'Y':
+ case 'Z':
+ case 'a': case 'b': case 'c': case 'd': case 'e':
+ case 'f': case 'g': case 'h': case 'i': case 'j':
+ case 'k': case 'l': case 'm': case 'n': case 'o':
+ case 'p': case 'q': case 'r': case 's': case 't':
+ case 'u': case 'v': case 'w': case 'x': case 'y':
+ case 'z':
+ ASSERT (is != 0);
+ break;
+ default:
+ ASSERT (is == 0);
+ break;
+ }
+ break;
+ }
if (argc > 1)
switch (argv[1][0])
- in the "POSIX" locale (which is usually the same as the "C" locale),
the blank characters include only the ASCII <space> and <tab>
characters. */
- {
- int c;
-
- for (c = 0; c < 0x100; c++)
- switch (c)
- {
- case '\t':
- #if !(defined __FreeBSD__ || defined __NetBSD__)
- case '\v':
- #endif
- #if !defined __NetBSD__
- case '\f':
- #endif
- case ' ': case '!': case '"': case '#': case '%':
- case '&': case '\'': case '(': case ')': case '*':
- case '+': case ',': case '-': case '.': case '/':
- case '0': case '1': case '2': case '3': case '4':
- case '5': case '6': case '7': case '8': case '9':
- case ':': case ';': case '<': case '=': case '>':
- case '?':
- case 'A': case 'B': case 'C': case 'D': case 'E':
- case 'F': case 'G': case 'H': case 'I': case 'J':
- case 'K': case 'L': case 'M': case 'N': case 'O':
- case 'P': case 'Q': case 'R': case 'S': case 'T':
- case 'U': case 'V': case 'W': case 'X': case 'Y':
- case 'Z':
- case '[': case '\\': case ']': case '^': case '_':
- case 'a': case 'b': case 'c': case 'd': case 'e':
- case 'f': case 'g': case 'h': case 'i': case 'j':
- case 'k': case 'l': case 'm': case 'n': case 'o':
- case 'p': case 'q': case 'r': case 's': case 't':
- case 'u': case 'v': case 'w': case 'x': case 'y':
- case 'z': case '{': case '|': case '}': case '~':
- /* c is in the ISO C "basic character set". */
- buf[0] = (unsigned char) c;
- is = for_character (buf, 1);
- if (c == '\t' || c == ' ')
- ASSERT (is != 0);
- else
- ASSERT (is == 0);
- break;
- }
- }
+ for (int c = 0; c < 0x100; c++)
+ switch (c)
+ {
+ case '\t':
+ #if !(defined __FreeBSD__ || defined __NetBSD__)
+ case '\v':
+ #endif
+ #if !defined __NetBSD__
+ case '\f':
+ #endif
+ case ' ': case '!': case '"': case '#': case '%':
+ case '&': case '\'': case '(': case ')': case '*':
+ case '+': case ',': case '-': case '.': case '/':
+ case '0': case '1': case '2': case '3': case '4':
+ case '5': case '6': case '7': case '8': case '9':
+ case ':': case ';': case '<': case '=': case '>':
+ case '?':
+ case 'A': case 'B': case 'C': case 'D': case 'E':
+ case 'F': case 'G': case 'H': case 'I': case 'J':
+ case 'K': case 'L': case 'M': case 'N': case 'O':
+ case 'P': case 'Q': case 'R': case 'S': case 'T':
+ case 'U': case 'V': case 'W': case 'X': case 'Y':
+ case 'Z':
+ case '[': case '\\': case ']': case '^': case '_':
+ case 'a': case 'b': case 'c': case 'd': case 'e':
+ case 'f': case 'g': case 'h': case 'i': case 'j':
+ case 'k': case 'l': case 'm': case 'n': case 'o':
+ case 'p': case 'q': case 'r': case 's': case 't':
+ case 'u': case 'v': case 'w': case 'x': case 'y':
+ case 'z': case '{': case '|': case '}': case '~':
+ /* c is in the ISO C "basic character set". */
+ buf[0] = (unsigned char) c;
+ is = for_character (buf, 1);
+ if (c == '\t' || c == ' ')
+ ASSERT (is != 0);
+ else
+ ASSERT (is == 0);
+ break;
+ }
if (argc > 1)
switch (argv[1][0])
POSIX specifies in
<https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap07.html>
no explicit list of control characters. */
- {
- int c;
-
- for (c = 0; c < 0x100; c++)
- switch (c)
- {
- case '\t': case '\v': case '\f':
- case ' ': case '!': case '"': case '#': case '%':
- case '&': case '\'': case '(': case ')': case '*':
- case '+': case ',': case '-': case '.': case '/':
- case '0': case '1': case '2': case '3': case '4':
- case '5': case '6': case '7': case '8': case '9':
- case ':': case ';': case '<': case '=': case '>':
- case '?':
- case 'A': case 'B': case 'C': case 'D': case 'E':
- case 'F': case 'G': case 'H': case 'I': case 'J':
- case 'K': case 'L': case 'M': case 'N': case 'O':
- case 'P': case 'Q': case 'R': case 'S': case 'T':
- case 'U': case 'V': case 'W': case 'X': case 'Y':
- case 'Z':
- case '[': case '\\': case ']': case '^': case '_':
- case 'a': case 'b': case 'c': case 'd': case 'e':
- case 'f': case 'g': case 'h': case 'i': case 'j':
- case 'k': case 'l': case 'm': case 'n': case 'o':
- case 'p': case 'q': case 'r': case 's': case 't':
- case 'u': case 'v': case 'w': case 'x': case 'y':
- case 'z': case '{': case '|': case '}': case '~':
- /* c is in the ISO C "basic character set". */
- buf[0] = (unsigned char) c;
- is = for_character (buf, 1);
- switch (c)
- {
- case '\t': case '\v': case '\f':
- ASSERT (is != 0);
- break;
- default:
- ASSERT (is == 0);
- break;
- }
- break;
- }
- }
+ for (int c = 0; c < 0x100; c++)
+ switch (c)
+ {
+ case '\t': case '\v': case '\f':
+ case ' ': case '!': case '"': case '#': case '%':
+ case '&': case '\'': case '(': case ')': case '*':
+ case '+': case ',': case '-': case '.': case '/':
+ case '0': case '1': case '2': case '3': case '4':
+ case '5': case '6': case '7': case '8': case '9':
+ case ':': case ';': case '<': case '=': case '>':
+ case '?':
+ case 'A': case 'B': case 'C': case 'D': case 'E':
+ case 'F': case 'G': case 'H': case 'I': case 'J':
+ case 'K': case 'L': case 'M': case 'N': case 'O':
+ case 'P': case 'Q': case 'R': case 'S': case 'T':
+ case 'U': case 'V': case 'W': case 'X': case 'Y':
+ case 'Z':
+ case '[': case '\\': case ']': case '^': case '_':
+ case 'a': case 'b': case 'c': case 'd': case 'e':
+ case 'f': case 'g': case 'h': case 'i': case 'j':
+ case 'k': case 'l': case 'm': case 'n': case 'o':
+ case 'p': case 'q': case 'r': case 's': case 't':
+ case 'u': case 'v': case 'w': case 'x': case 'y':
+ case 'z': case '{': case '|': case '}': case '~':
+ /* c is in the ISO C "basic character set". */
+ buf[0] = (unsigned char) c;
+ is = for_character (buf, 1);
+ switch (c)
+ {
+ case '\t': case '\v': case '\f':
+ ASSERT (is != 0);
+ break;
+ default:
+ ASSERT (is == 0);
+ break;
+ }
+ break;
+ }
if (argc > 1)
switch (argv[1][0])
/* Test single-byte characters.
ISO C 99 sections 7.25.2.1.5 and 5.2.1 specify that the decimal digits
include only the ASCII 0 ... 9 characters. */
- {
- int c;
-
- for (c = 0; c < 0x100; c++)
- switch (c)
- {
- case '\t': case '\v': case '\f':
- case ' ': case '!': case '"': case '#': case '%':
- case '&': case '\'': case '(': case ')': case '*':
- case '+': case ',': case '-': case '.': case '/':
- case '0': case '1': case '2': case '3': case '4':
- case '5': case '6': case '7': case '8': case '9':
- case ':': case ';': case '<': case '=': case '>':
- case '?':
- case 'A': case 'B': case 'C': case 'D': case 'E':
- case 'F': case 'G': case 'H': case 'I': case 'J':
- case 'K': case 'L': case 'M': case 'N': case 'O':
- case 'P': case 'Q': case 'R': case 'S': case 'T':
- case 'U': case 'V': case 'W': case 'X': case 'Y':
- case 'Z':
- case '[': case '\\': case ']': case '^': case '_':
- case 'a': case 'b': case 'c': case 'd': case 'e':
- case 'f': case 'g': case 'h': case 'i': case 'j':
- case 'k': case 'l': case 'm': case 'n': case 'o':
- case 'p': case 'q': case 'r': case 's': case 't':
- case 'u': case 'v': case 'w': case 'x': case 'y':
- case 'z': case '{': case '|': case '}': case '~':
- /* c is in the ISO C "basic character set". */
- buf[0] = (unsigned char) c;
- is = for_character (buf, 1);
- switch (c)
- {
- case '0': case '1': case '2': case '3': case '4':
- case '5': case '6': case '7': case '8': case '9':
- ASSERT (is != 0);
- break;
- default:
- ASSERT (is == 0);
- break;
- }
- break;
- }
- }
+ for (int c = 0; c < 0x100; c++)
+ switch (c)
+ {
+ case '\t': case '\v': case '\f':
+ case ' ': case '!': case '"': case '#': case '%':
+ case '&': case '\'': case '(': case ')': case '*':
+ case '+': case ',': case '-': case '.': case '/':
+ case '0': case '1': case '2': case '3': case '4':
+ case '5': case '6': case '7': case '8': case '9':
+ case ':': case ';': case '<': case '=': case '>':
+ case '?':
+ case 'A': case 'B': case 'C': case 'D': case 'E':
+ case 'F': case 'G': case 'H': case 'I': case 'J':
+ case 'K': case 'L': case 'M': case 'N': case 'O':
+ case 'P': case 'Q': case 'R': case 'S': case 'T':
+ case 'U': case 'V': case 'W': case 'X': case 'Y':
+ case 'Z':
+ case '[': case '\\': case ']': case '^': case '_':
+ case 'a': case 'b': case 'c': case 'd': case 'e':
+ case 'f': case 'g': case 'h': case 'i': case 'j':
+ case 'k': case 'l': case 'm': case 'n': case 'o':
+ case 'p': case 'q': case 'r': case 's': case 't':
+ case 'u': case 'v': case 'w': case 'x': case 'y':
+ case 'z': case '{': case '|': case '}': case '~':
+ /* c is in the ISO C "basic character set". */
+ buf[0] = (unsigned char) c;
+ is = for_character (buf, 1);
+ switch (c)
+ {
+ case '0': case '1': case '2': case '3': case '4':
+ case '5': case '6': case '7': case '8': case '9':
+ ASSERT (is != 0);
+ break;
+ default:
+ ASSERT (is == 0);
+ break;
+ }
+ break;
+ }
if (argc > 1)
switch (argv[1][0])
POSIX specifies in
<https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap07.html>
no explicit list of graphic characters. */
- {
- int c;
-
- for (c = 0; c < 0x100; c++)
- switch (c)
- {
- case '\t': case '\v': case '\f':
- case ' ': case '!': case '"': case '#': case '%':
- case '&': case '\'': case '(': case ')': case '*':
- case '+': case ',': case '-': case '.': case '/':
- case '0': case '1': case '2': case '3': case '4':
- case '5': case '6': case '7': case '8': case '9':
- case ':': case ';': case '<': case '=': case '>':
- case '?':
- case 'A': case 'B': case 'C': case 'D': case 'E':
- case 'F': case 'G': case 'H': case 'I': case 'J':
- case 'K': case 'L': case 'M': case 'N': case 'O':
- case 'P': case 'Q': case 'R': case 'S': case 'T':
- case 'U': case 'V': case 'W': case 'X': case 'Y':
- case 'Z':
- case '[': case '\\': case ']': case '^': case '_':
- case 'a': case 'b': case 'c': case 'd': case 'e':
- case 'f': case 'g': case 'h': case 'i': case 'j':
- case 'k': case 'l': case 'm': case 'n': case 'o':
- case 'p': case 'q': case 'r': case 's': case 't':
- case 'u': case 'v': case 'w': case 'x': case 'y':
- case 'z': case '{': case '|': case '}': case '~':
- /* c is in the ISO C "basic character set". */
- buf[0] = (unsigned char) c;
- is = for_character (buf, 1);
- switch (c)
- {
- case '\t': case '\v': case '\f':
- case ' ':
- ASSERT (is == 0);
- break;
- default:
- ASSERT (is != 0);
- break;
- }
- break;
- }
- }
+ for (int c = 0; c < 0x100; c++)
+ switch (c)
+ {
+ case '\t': case '\v': case '\f':
+ case ' ': case '!': case '"': case '#': case '%':
+ case '&': case '\'': case '(': case ')': case '*':
+ case '+': case ',': case '-': case '.': case '/':
+ case '0': case '1': case '2': case '3': case '4':
+ case '5': case '6': case '7': case '8': case '9':
+ case ':': case ';': case '<': case '=': case '>':
+ case '?':
+ case 'A': case 'B': case 'C': case 'D': case 'E':
+ case 'F': case 'G': case 'H': case 'I': case 'J':
+ case 'K': case 'L': case 'M': case 'N': case 'O':
+ case 'P': case 'Q': case 'R': case 'S': case 'T':
+ case 'U': case 'V': case 'W': case 'X': case 'Y':
+ case 'Z':
+ case '[': case '\\': case ']': case '^': case '_':
+ case 'a': case 'b': case 'c': case 'd': case 'e':
+ case 'f': case 'g': case 'h': case 'i': case 'j':
+ case 'k': case 'l': case 'm': case 'n': case 'o':
+ case 'p': case 'q': case 'r': case 's': case 't':
+ case 'u': case 'v': case 'w': case 'x': case 'y':
+ case 'z': case '{': case '|': case '}': case '~':
+ /* c is in the ISO C "basic character set". */
+ buf[0] = (unsigned char) c;
+ is = for_character (buf, 1);
+ switch (c)
+ {
+ case '\t': case '\v': case '\f':
+ case ' ':
+ ASSERT (is == 0);
+ break;
+ default:
+ ASSERT (is != 0);
+ break;
+ }
+ break;
+ }
if (argc > 1)
switch (argv[1][0])
- in the "POSIX" locale (which is usually the same as the "C" locale),
the lowercase characters include only the ASCII a ... z characters.
*/
- {
- int c;
-
- for (c = 0; c < 0x100; c++)
- switch (c)
- {
- case '\t': case '\v': case '\f':
- case ' ': case '!': case '"': case '#': case '%':
- case '&': case '\'': case '(': case ')': case '*':
- case '+': case ',': case '-': case '.': case '/':
- case '0': case '1': case '2': case '3': case '4':
- case '5': case '6': case '7': case '8': case '9':
- case ':': case ';': case '<': case '=': case '>':
- case '?':
- case 'A': case 'B': case 'C': case 'D': case 'E':
- case 'F': case 'G': case 'H': case 'I': case 'J':
- case 'K': case 'L': case 'M': case 'N': case 'O':
- case 'P': case 'Q': case 'R': case 'S': case 'T':
- case 'U': case 'V': case 'W': case 'X': case 'Y':
- case 'Z':
- case '[': case '\\': case ']': case '^': case '_':
- case 'a': case 'b': case 'c': case 'd': case 'e':
- case 'f': case 'g': case 'h': case 'i': case 'j':
- case 'k': case 'l': case 'm': case 'n': case 'o':
- case 'p': case 'q': case 'r': case 's': case 't':
- case 'u': case 'v': case 'w': case 'x': case 'y':
- case 'z': case '{': case '|': case '}': case '~':
- /* c is in the ISO C "basic character set". */
- buf[0] = (unsigned char) c;
- is = for_character (buf, 1);
- switch (c)
- {
- case 'a': case 'b': case 'c': case 'd': case 'e':
- case 'f': case 'g': case 'h': case 'i': case 'j':
- case 'k': case 'l': case 'm': case 'n': case 'o':
- case 'p': case 'q': case 'r': case 's': case 't':
- case 'u': case 'v': case 'w': case 'x': case 'y':
- case 'z':
- ASSERT (is != 0);
- break;
- default:
- ASSERT (is == 0);
- break;
- }
- break;
- }
- }
+ for (int c = 0; c < 0x100; c++)
+ switch (c)
+ {
+ case '\t': case '\v': case '\f':
+ case ' ': case '!': case '"': case '#': case '%':
+ case '&': case '\'': case '(': case ')': case '*':
+ case '+': case ',': case '-': case '.': case '/':
+ case '0': case '1': case '2': case '3': case '4':
+ case '5': case '6': case '7': case '8': case '9':
+ case ':': case ';': case '<': case '=': case '>':
+ case '?':
+ case 'A': case 'B': case 'C': case 'D': case 'E':
+ case 'F': case 'G': case 'H': case 'I': case 'J':
+ case 'K': case 'L': case 'M': case 'N': case 'O':
+ case 'P': case 'Q': case 'R': case 'S': case 'T':
+ case 'U': case 'V': case 'W': case 'X': case 'Y':
+ case 'Z':
+ case '[': case '\\': case ']': case '^': case '_':
+ case 'a': case 'b': case 'c': case 'd': case 'e':
+ case 'f': case 'g': case 'h': case 'i': case 'j':
+ case 'k': case 'l': case 'm': case 'n': case 'o':
+ case 'p': case 'q': case 'r': case 's': case 't':
+ case 'u': case 'v': case 'w': case 'x': case 'y':
+ case 'z': case '{': case '|': case '}': case '~':
+ /* c is in the ISO C "basic character set". */
+ buf[0] = (unsigned char) c;
+ is = for_character (buf, 1);
+ switch (c)
+ {
+ case 'a': case 'b': case 'c': case 'd': case 'e':
+ case 'f': case 'g': case 'h': case 'i': case 'j':
+ case 'k': case 'l': case 'm': case 'n': case 'o':
+ case 'p': case 'q': case 'r': case 's': case 't':
+ case 'u': case 'v': case 'w': case 'x': case 'y':
+ case 'z':
+ ASSERT (is != 0);
+ break;
+ default:
+ ASSERT (is == 0);
+ break;
+ }
+ break;
+ }
if (argc > 1)
switch (argv[1][0])
POSIX specifies in
<https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap07.html>
no explicit list of printable characters. */
- {
- int c;
-
- for (c = 0; c < 0x100; c++)
- switch (c)
- {
- case '\t': case '\v': case '\f':
- case ' ': case '!': case '"': case '#': case '%':
- case '&': case '\'': case '(': case ')': case '*':
- case '+': case ',': case '-': case '.': case '/':
- case '0': case '1': case '2': case '3': case '4':
- case '5': case '6': case '7': case '8': case '9':
- case ':': case ';': case '<': case '=': case '>':
- case '?':
- case 'A': case 'B': case 'C': case 'D': case 'E':
- case 'F': case 'G': case 'H': case 'I': case 'J':
- case 'K': case 'L': case 'M': case 'N': case 'O':
- case 'P': case 'Q': case 'R': case 'S': case 'T':
- case 'U': case 'V': case 'W': case 'X': case 'Y':
- case 'Z':
- case '[': case '\\': case ']': case '^': case '_':
- case 'a': case 'b': case 'c': case 'd': case 'e':
- case 'f': case 'g': case 'h': case 'i': case 'j':
- case 'k': case 'l': case 'm': case 'n': case 'o':
- case 'p': case 'q': case 'r': case 's': case 't':
- case 'u': case 'v': case 'w': case 'x': case 'y':
- case 'z': case '{': case '|': case '}': case '~':
- /* c is in the ISO C "basic character set". */
- buf[0] = (unsigned char) c;
- is = for_character (buf, 1);
- switch (c)
- {
- case '\t': case '\v': case '\f':
- ASSERT (is == 0);
- break;
- default:
- ASSERT (is != 0);
- break;
- }
- break;
- }
- }
+ for (int c = 0; c < 0x100; c++)
+ switch (c)
+ {
+ case '\t': case '\v': case '\f':
+ case ' ': case '!': case '"': case '#': case '%':
+ case '&': case '\'': case '(': case ')': case '*':
+ case '+': case ',': case '-': case '.': case '/':
+ case '0': case '1': case '2': case '3': case '4':
+ case '5': case '6': case '7': case '8': case '9':
+ case ':': case ';': case '<': case '=': case '>':
+ case '?':
+ case 'A': case 'B': case 'C': case 'D': case 'E':
+ case 'F': case 'G': case 'H': case 'I': case 'J':
+ case 'K': case 'L': case 'M': case 'N': case 'O':
+ case 'P': case 'Q': case 'R': case 'S': case 'T':
+ case 'U': case 'V': case 'W': case 'X': case 'Y':
+ case 'Z':
+ case '[': case '\\': case ']': case '^': case '_':
+ case 'a': case 'b': case 'c': case 'd': case 'e':
+ case 'f': case 'g': case 'h': case 'i': case 'j':
+ case 'k': case 'l': case 'm': case 'n': case 'o':
+ case 'p': case 'q': case 'r': case 's': case 't':
+ case 'u': case 'v': case 'w': case 'x': case 'y':
+ case 'z': case '{': case '|': case '}': case '~':
+ /* c is in the ISO C "basic character set". */
+ buf[0] = (unsigned char) c;
+ is = for_character (buf, 1);
+ switch (c)
+ {
+ case '\t': case '\v': case '\f':
+ ASSERT (is == 0);
+ break;
+ default:
+ ASSERT (is != 0);
+ break;
+ }
+ break;
+ }
if (argc > 1)
switch (argv[1][0])
POSIX specifies in
<https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap07.html>
no explicit list of punctuation or symbol characters. */
- {
- int c;
-
- for (c = 0; c < 0x100; c++)
- switch (c)
- {
- case '\t': case '\v': case '\f':
- case ' ': case '!': case '"': case '#': case '%':
- case '&': case '\'': case '(': case ')': case '*':
- case '+': case ',': case '-': case '.': case '/':
- case '0': case '1': case '2': case '3': case '4':
- case '5': case '6': case '7': case '8': case '9':
- case ':': case ';': case '<': case '=': case '>':
- case '?':
- case 'A': case 'B': case 'C': case 'D': case 'E':
- case 'F': case 'G': case 'H': case 'I': case 'J':
- case 'K': case 'L': case 'M': case 'N': case 'O':
- case 'P': case 'Q': case 'R': case 'S': case 'T':
- case 'U': case 'V': case 'W': case 'X': case 'Y':
- case 'Z':
- case '[': case '\\': case ']': case '^': case '_':
- case 'a': case 'b': case 'c': case 'd': case 'e':
- case 'f': case 'g': case 'h': case 'i': case 'j':
- case 'k': case 'l': case 'm': case 'n': case 'o':
- case 'p': case 'q': case 'r': case 's': case 't':
- case 'u': case 'v': case 'w': case 'x': case 'y':
- case 'z': case '{': case '|': case '}': case '~':
- /* c is in the ISO C "basic character set". */
- buf[0] = (unsigned char) c;
- is = for_character (buf, 1);
- switch (c)
- {
- case ' ':
- case '0': case '1': case '2': case '3': case '4':
- case '5': case '6': case '7': case '8': case '9':
- case 'A': case 'B': case 'C': case 'D': case 'E':
- case 'F': case 'G': case 'H': case 'I': case 'J':
- case 'K': case 'L': case 'M': case 'N': case 'O':
- case 'P': case 'Q': case 'R': case 'S': case 'T':
- case 'U': case 'V': case 'W': case 'X': case 'Y':
- case 'Z':
- case 'a': case 'b': case 'c': case 'd': case 'e':
- case 'f': case 'g': case 'h': case 'i': case 'j':
- case 'k': case 'l': case 'm': case 'n': case 'o':
- case 'p': case 'q': case 'r': case 's': case 't':
- case 'u': case 'v': case 'w': case 'x': case 'y':
- case 'z':
- /* c is an alphanumeric or space character. */
- ASSERT (is == 0);
- break;
- case '!': case '"': case '#': case '%':
- case '&': case '\'': case '(': case ')': case '*':
- case '+': case ',': case '-': case '.': case '/':
- case ':': case ';': case '<': case '=': case '>':
- case '?':
- case '[': case '\\': case ']': case '^': case '_':
- case '{': case '|': case '}': case '~':
- /* These characters are usually expected to be punctuation or
- symbol characters. */
- ASSERT (is != 0);
- break;
- default:
- ASSERT (is == 0);
- break;
- }
- break;
- }
- }
+ for (int c = 0; c < 0x100; c++)
+ switch (c)
+ {
+ case '\t': case '\v': case '\f':
+ case ' ': case '!': case '"': case '#': case '%':
+ case '&': case '\'': case '(': case ')': case '*':
+ case '+': case ',': case '-': case '.': case '/':
+ case '0': case '1': case '2': case '3': case '4':
+ case '5': case '6': case '7': case '8': case '9':
+ case ':': case ';': case '<': case '=': case '>':
+ case '?':
+ case 'A': case 'B': case 'C': case 'D': case 'E':
+ case 'F': case 'G': case 'H': case 'I': case 'J':
+ case 'K': case 'L': case 'M': case 'N': case 'O':
+ case 'P': case 'Q': case 'R': case 'S': case 'T':
+ case 'U': case 'V': case 'W': case 'X': case 'Y':
+ case 'Z':
+ case '[': case '\\': case ']': case '^': case '_':
+ case 'a': case 'b': case 'c': case 'd': case 'e':
+ case 'f': case 'g': case 'h': case 'i': case 'j':
+ case 'k': case 'l': case 'm': case 'n': case 'o':
+ case 'p': case 'q': case 'r': case 's': case 't':
+ case 'u': case 'v': case 'w': case 'x': case 'y':
+ case 'z': case '{': case '|': case '}': case '~':
+ /* c is in the ISO C "basic character set". */
+ buf[0] = (unsigned char) c;
+ is = for_character (buf, 1);
+ switch (c)
+ {
+ case ' ':
+ case '0': case '1': case '2': case '3': case '4':
+ case '5': case '6': case '7': case '8': case '9':
+ case 'A': case 'B': case 'C': case 'D': case 'E':
+ case 'F': case 'G': case 'H': case 'I': case 'J':
+ case 'K': case 'L': case 'M': case 'N': case 'O':
+ case 'P': case 'Q': case 'R': case 'S': case 'T':
+ case 'U': case 'V': case 'W': case 'X': case 'Y':
+ case 'Z':
+ case 'a': case 'b': case 'c': case 'd': case 'e':
+ case 'f': case 'g': case 'h': case 'i': case 'j':
+ case 'k': case 'l': case 'm': case 'n': case 'o':
+ case 'p': case 'q': case 'r': case 's': case 't':
+ case 'u': case 'v': case 'w': case 'x': case 'y':
+ case 'z':
+ /* c is an alphanumeric or space character. */
+ ASSERT (is == 0);
+ break;
+ case '!': case '"': case '#': case '%':
+ case '&': case '\'': case '(': case ')': case '*':
+ case '+': case ',': case '-': case '.': case '/':
+ case ':': case ';': case '<': case '=': case '>':
+ case '?':
+ case '[': case '\\': case ']': case '^': case '_':
+ case '{': case '|': case '}': case '~':
+ /* These characters are usually expected to be punctuation or
+ symbol characters. */
+ ASSERT (is != 0);
+ break;
+ default:
+ ASSERT (is == 0);
+ break;
+ }
+ break;
+ }
if (argc > 1)
switch (argv[1][0])
- in the "POSIX" locale (which is usually the same as the "C" locale),
the white-space characters include only the ASCII <space>, <form-feed>,
<newline>, <carriage-return>, <tab>, <vertical-tab> characters. */
- {
- int c;
-
- for (c = 0; c < 0x100; c++)
- switch (c)
- {
- case '\f': case '\n': case '\r': case '\t': case '\v':
- case ' ': case '!': case '"': case '#': case '%':
- case '&': case '\'': case '(': case ')': case '*':
- case '+': case ',': case '-': case '.': case '/':
- case '0': case '1': case '2': case '3': case '4':
- case '5': case '6': case '7': case '8': case '9':
- case ':': case ';': case '<': case '=': case '>':
- case '?':
- case 'A': case 'B': case 'C': case 'D': case 'E':
- case 'F': case 'G': case 'H': case 'I': case 'J':
- case 'K': case 'L': case 'M': case 'N': case 'O':
- case 'P': case 'Q': case 'R': case 'S': case 'T':
- case 'U': case 'V': case 'W': case 'X': case 'Y':
- case 'Z':
- case '[': case '\\': case ']': case '^': case '_':
- case 'a': case 'b': case 'c': case 'd': case 'e':
- case 'f': case 'g': case 'h': case 'i': case 'j':
- case 'k': case 'l': case 'm': case 'n': case 'o':
- case 'p': case 'q': case 'r': case 's': case 't':
- case 'u': case 'v': case 'w': case 'x': case 'y':
- case 'z': case '{': case '|': case '}': case '~':
- /* c is in the ISO C "basic character set" or one of the explicitly
- mentioned white-space characters. */
- buf[0] = (unsigned char) c;
- is = for_character (buf, 1);
- switch (c)
- {
- case ' ': case '\f': case '\n': case '\r': case '\t': case '\v':
- ASSERT (is != 0);
- break;
- default:
- ASSERT (is == 0);
- break;
- }
- break;
- }
- }
+ for (int c = 0; c < 0x100; c++)
+ switch (c)
+ {
+ case '\f': case '\n': case '\r': case '\t': case '\v':
+ case ' ': case '!': case '"': case '#': case '%':
+ case '&': case '\'': case '(': case ')': case '*':
+ case '+': case ',': case '-': case '.': case '/':
+ case '0': case '1': case '2': case '3': case '4':
+ case '5': case '6': case '7': case '8': case '9':
+ case ':': case ';': case '<': case '=': case '>':
+ case '?':
+ case 'A': case 'B': case 'C': case 'D': case 'E':
+ case 'F': case 'G': case 'H': case 'I': case 'J':
+ case 'K': case 'L': case 'M': case 'N': case 'O':
+ case 'P': case 'Q': case 'R': case 'S': case 'T':
+ case 'U': case 'V': case 'W': case 'X': case 'Y':
+ case 'Z':
+ case '[': case '\\': case ']': case '^': case '_':
+ case 'a': case 'b': case 'c': case 'd': case 'e':
+ case 'f': case 'g': case 'h': case 'i': case 'j':
+ case 'k': case 'l': case 'm': case 'n': case 'o':
+ case 'p': case 'q': case 'r': case 's': case 't':
+ case 'u': case 'v': case 'w': case 'x': case 'y':
+ case 'z': case '{': case '|': case '}': case '~':
+ /* c is in the ISO C "basic character set" or one of the explicitly
+ mentioned white-space characters. */
+ buf[0] = (unsigned char) c;
+ is = for_character (buf, 1);
+ switch (c)
+ {
+ case ' ': case '\f': case '\n': case '\r': case '\t': case '\v':
+ ASSERT (is != 0);
+ break;
+ default:
+ ASSERT (is == 0);
+ break;
+ }
+ break;
+ }
if (argc > 1)
switch (argv[1][0])
- in the "POSIX" locale (which is usually the same as the "C" locale),
the uppercase characters include only the ASCII A ... Z characters.
*/
- {
- int c;
-
- for (c = 0; c < 0x100; c++)
- switch (c)
- {
- case '\t': case '\v': case '\f':
- case ' ': case '!': case '"': case '#': case '%':
- case '&': case '\'': case '(': case ')': case '*':
- case '+': case ',': case '-': case '.': case '/':
- case '0': case '1': case '2': case '3': case '4':
- case '5': case '6': case '7': case '8': case '9':
- case ':': case ';': case '<': case '=': case '>':
- case '?':
- case 'A': case 'B': case 'C': case 'D': case 'E':
- case 'F': case 'G': case 'H': case 'I': case 'J':
- case 'K': case 'L': case 'M': case 'N': case 'O':
- case 'P': case 'Q': case 'R': case 'S': case 'T':
- case 'U': case 'V': case 'W': case 'X': case 'Y':
- case 'Z':
- case '[': case '\\': case ']': case '^': case '_':
- case 'a': case 'b': case 'c': case 'd': case 'e':
- case 'f': case 'g': case 'h': case 'i': case 'j':
- case 'k': case 'l': case 'm': case 'n': case 'o':
- case 'p': case 'q': case 'r': case 's': case 't':
- case 'u': case 'v': case 'w': case 'x': case 'y':
- case 'z': case '{': case '|': case '}': case '~':
- /* c is in the ISO C "basic character set". */
- buf[0] = (unsigned char) c;
- is = for_character (buf, 1);
- switch (c)
- {
- case 'A': case 'B': case 'C': case 'D': case 'E':
- case 'F': case 'G': case 'H': case 'I': case 'J':
- case 'K': case 'L': case 'M': case 'N': case 'O':
- case 'P': case 'Q': case 'R': case 'S': case 'T':
- case 'U': case 'V': case 'W': case 'X': case 'Y':
- case 'Z':
- ASSERT (is != 0);
- break;
- default:
- ASSERT (is == 0);
- break;
- }
- break;
- }
- }
+ for (int c = 0; c < 0x100; c++)
+ switch (c)
+ {
+ case '\t': case '\v': case '\f':
+ case ' ': case '!': case '"': case '#': case '%':
+ case '&': case '\'': case '(': case ')': case '*':
+ case '+': case ',': case '-': case '.': case '/':
+ case '0': case '1': case '2': case '3': case '4':
+ case '5': case '6': case '7': case '8': case '9':
+ case ':': case ';': case '<': case '=': case '>':
+ case '?':
+ case 'A': case 'B': case 'C': case 'D': case 'E':
+ case 'F': case 'G': case 'H': case 'I': case 'J':
+ case 'K': case 'L': case 'M': case 'N': case 'O':
+ case 'P': case 'Q': case 'R': case 'S': case 'T':
+ case 'U': case 'V': case 'W': case 'X': case 'Y':
+ case 'Z':
+ case '[': case '\\': case ']': case '^': case '_':
+ case 'a': case 'b': case 'c': case 'd': case 'e':
+ case 'f': case 'g': case 'h': case 'i': case 'j':
+ case 'k': case 'l': case 'm': case 'n': case 'o':
+ case 'p': case 'q': case 'r': case 's': case 't':
+ case 'u': case 'v': case 'w': case 'x': case 'y':
+ case 'z': case '{': case '|': case '}': case '~':
+ /* c is in the ISO C "basic character set". */
+ buf[0] = (unsigned char) c;
+ is = for_character (buf, 1);
+ switch (c)
+ {
+ case 'A': case 'B': case 'C': case 'D': case 'E':
+ case 'F': case 'G': case 'H': case 'I': case 'J':
+ case 'K': case 'L': case 'M': case 'N': case 'O':
+ case 'P': case 'Q': case 'R': case 'S': case 'T':
+ case 'U': case 'V': case 'W': case 'X': case 'Y':
+ case 'Z':
+ ASSERT (is != 0);
+ break;
+ default:
+ ASSERT (is == 0);
+ break;
+ }
+ break;
+ }
if (argc > 1)
switch (argv[1][0])
/* Test single-byte characters.
ISO C 99 sections 7.25.2.1.12 and 6.4.4.1 specify that the hexadecimal
digits include only the ASCII 0 ... 9 A ... F a ... f characters. */
- {
- int c;
-
- for (c = 0; c < 0x100; c++)
- switch (c)
- {
- case '\t': case '\v': case '\f':
- case ' ': case '!': case '"': case '#': case '%':
- case '&': case '\'': case '(': case ')': case '*':
- case '+': case ',': case '-': case '.': case '/':
- case '0': case '1': case '2': case '3': case '4':
- case '5': case '6': case '7': case '8': case '9':
- case ':': case ';': case '<': case '=': case '>':
- case '?':
- case 'A': case 'B': case 'C': case 'D': case 'E':
- case 'F': case 'G': case 'H': case 'I': case 'J':
- case 'K': case 'L': case 'M': case 'N': case 'O':
- case 'P': case 'Q': case 'R': case 'S': case 'T':
- case 'U': case 'V': case 'W': case 'X': case 'Y':
- case 'Z':
- case '[': case '\\': case ']': case '^': case '_':
- case 'a': case 'b': case 'c': case 'd': case 'e':
- case 'f': case 'g': case 'h': case 'i': case 'j':
- case 'k': case 'l': case 'm': case 'n': case 'o':
- case 'p': case 'q': case 'r': case 's': case 't':
- case 'u': case 'v': case 'w': case 'x': case 'y':
- case 'z': case '{': case '|': case '}': case '~':
- /* c is in the ISO C "basic character set". */
- buf[0] = (unsigned char) c;
- is = for_character (buf, 1);
- switch (c)
- {
- case '0': case '1': case '2': case '3': case '4':
- case '5': case '6': case '7': case '8': case '9':
- case 'A': case 'B': case 'C': case 'D': case 'E': case 'F':
- case 'a': case 'b': case 'c': case 'd': case 'e': case 'f':
- ASSERT (is != 0);
- break;
- default:
- ASSERT (is == 0);
- break;
- }
- break;
- }
- }
+ for (int c = 0; c < 0x100; c++)
+ switch (c)
+ {
+ case '\t': case '\v': case '\f':
+ case ' ': case '!': case '"': case '#': case '%':
+ case '&': case '\'': case '(': case ')': case '*':
+ case '+': case ',': case '-': case '.': case '/':
+ case '0': case '1': case '2': case '3': case '4':
+ case '5': case '6': case '7': case '8': case '9':
+ case ':': case ';': case '<': case '=': case '>':
+ case '?':
+ case 'A': case 'B': case 'C': case 'D': case 'E':
+ case 'F': case 'G': case 'H': case 'I': case 'J':
+ case 'K': case 'L': case 'M': case 'N': case 'O':
+ case 'P': case 'Q': case 'R': case 'S': case 'T':
+ case 'U': case 'V': case 'W': case 'X': case 'Y':
+ case 'Z':
+ case '[': case '\\': case ']': case '^': case '_':
+ case 'a': case 'b': case 'c': case 'd': case 'e':
+ case 'f': case 'g': case 'h': case 'i': case 'j':
+ case 'k': case 'l': case 'm': case 'n': case 'o':
+ case 'p': case 'q': case 'r': case 's': case 't':
+ case 'u': case 'v': case 'w': case 'x': case 'y':
+ case 'z': case '{': case '|': case '}': case '~':
+ /* c is in the ISO C "basic character set". */
+ buf[0] = (unsigned char) c;
+ is = for_character (buf, 1);
+ switch (c)
+ {
+ case '0': case '1': case '2': case '3': case '4':
+ case '5': case '6': case '7': case '8': case '9':
+ case 'A': case 'B': case 'C': case 'D': case 'E': case 'F':
+ case 'a': case 'b': case 'c': case 'd': case 'e': case 'f':
+ ASSERT (is != 0);
+ break;
+ default:
+ ASSERT (is == 0);
+ break;
+ }
+ break;
+ }
if (argc > 1)
switch (argv[1][0])
}
/* Test single bytes. */
- {
- int c;
-
- for (c = 0; c < 0x100; c++)
- switch (c)
- {
- case '\t': case '\v': case '\f':
- case ' ': case '!': case '"': case '#': case '%':
- case '&': case '\'': case '(': case ')': case '*':
- case '+': case ',': case '-': case '.': case '/':
- case '0': case '1': case '2': case '3': case '4':
- case '5': case '6': case '7': case '8': case '9':
- case ':': case ';': case '<': case '=': case '>':
- case '?':
- case 'A': case 'B': case 'C': case 'D': case 'E':
- case 'F': case 'G': case 'H': case 'I': case 'J':
- case 'K': case 'L': case 'M': case 'N': case 'O':
- case 'P': case 'Q': case 'R': case 'S': case 'T':
- case 'U': case 'V': case 'W': case 'X': case 'Y':
- case 'Z':
- case '[': case '\\': case ']': case '^': case '_':
- case 'a': case 'b': case 'c': case 'd': case 'e':
- case 'f': case 'g': case 'h': case 'i': case 'j':
- case 'k': case 'l': case 'm': case 'n': case 'o':
- case 'p': case 'q': case 'r': case 's': case 't':
- case 'u': case 'v': case 'w': case 'x': case 'y':
- case 'z': case '{': case '|': case '}': case '~':
- /* c is in the ISO C "basic character set". */
- ret = c32rtomb (buf, btoc32 (c), NULL);
- ASSERT (ret == 1);
- ASSERT (buf[0] == (char) c);
- break;
- }
- }
+ for (int c = 0; c < 0x100; c++)
+ switch (c)
+ {
+ case '\t': case '\v': case '\f':
+ case ' ': case '!': case '"': case '#': case '%':
+ case '&': case '\'': case '(': case ')': case '*':
+ case '+': case ',': case '-': case '.': case '/':
+ case '0': case '1': case '2': case '3': case '4':
+ case '5': case '6': case '7': case '8': case '9':
+ case ':': case ';': case '<': case '=': case '>':
+ case '?':
+ case 'A': case 'B': case 'C': case 'D': case 'E':
+ case 'F': case 'G': case 'H': case 'I': case 'J':
+ case 'K': case 'L': case 'M': case 'N': case 'O':
+ case 'P': case 'Q': case 'R': case 'S': case 'T':
+ case 'U': case 'V': case 'W': case 'X': case 'Y':
+ case 'Z':
+ case '[': case '\\': case ']': case '^': case '_':
+ case 'a': case 'b': case 'c': case 'd': case 'e':
+ case 'f': case 'g': case 'h': case 'i': case 'j':
+ case 'k': case 'l': case 'm': case 'n': case 'o':
+ case 'p': case 'q': case 'r': case 's': case 't':
+ case 'u': case 'v': case 'w': case 'x': case 'y':
+ case 'z': case '{': case '|': case '}': case '~':
+ /* c is in the ISO C "basic character set". */
+ ret = c32rtomb (buf, btoc32 (c), NULL);
+ ASSERT (ret == 1);
+ ASSERT (buf[0] == (char) c);
+ break;
+ }
/* Test special calling convention, passing a NULL pointer. */
{
{
int codepage = atoi (argv[argc - 1]);
int result;
- int i;
result = 77;
- for (i = 1; i < argc - 1; i++)
+ for (int i = 1; i < argc - 1; i++)
{
int ret = test_one_locale (argv[i], codepage);
}
/* Test single bytes. */
- {
- int c;
-
- for (c = 0; c < 0x100; c++)
- switch (c)
- {
- case '\t': case '\v': case '\f':
- case ' ': case '!': case '"': case '#': case '%':
- case '&': case '\'': case '(': case ')': case '*':
- case '+': case ',': case '-': case '.': case '/':
- case '0': case '1': case '2': case '3': case '4':
- case '5': case '6': case '7': case '8': case '9':
- case ':': case ';': case '<': case '=': case '>':
- case '?':
- case 'A': case 'B': case 'C': case 'D': case 'E':
- case 'F': case 'G': case 'H': case 'I': case 'J':
- case 'K': case 'L': case 'M': case 'N': case 'O':
- case 'P': case 'Q': case 'R': case 'S': case 'T':
- case 'U': case 'V': case 'W': case 'X': case 'Y':
- case 'Z':
- case '[': case '\\': case ']': case '^': case '_':
- case 'a': case 'b': case 'c': case 'd': case 'e':
- case 'f': case 'g': case 'h': case 'i': case 'j':
- case 'k': case 'l': case 'm': case 'n': case 'o':
- case 'p': case 'q': case 'r': case 's': case 't':
- case 'u': case 'v': case 'w': case 'x': case 'y':
- case 'z': case '{': case '|': case '}': case '~':
- /* c is in the ISO C "basic character set". */
- ret = c32rtomb (buf, btoc32 (c), NULL);
- ASSERT (ret == 1);
- ASSERT (buf[0] == (char) c);
- break;
- }
- }
+ for (int c = 0; c < 0x100; c++)
+ switch (c)
+ {
+ case '\t': case '\v': case '\f':
+ case ' ': case '!': case '"': case '#': case '%':
+ case '&': case '\'': case '(': case ')': case '*':
+ case '+': case ',': case '-': case '.': case '/':
+ case '0': case '1': case '2': case '3': case '4':
+ case '5': case '6': case '7': case '8': case '9':
+ case ':': case ';': case '<': case '=': case '>':
+ case '?':
+ case 'A': case 'B': case 'C': case 'D': case 'E':
+ case 'F': case 'G': case 'H': case 'I': case 'J':
+ case 'K': case 'L': case 'M': case 'N': case 'O':
+ case 'P': case 'Q': case 'R': case 'S': case 'T':
+ case 'U': case 'V': case 'W': case 'X': case 'Y':
+ case 'Z':
+ case '[': case '\\': case ']': case '^': case '_':
+ case 'a': case 'b': case 'c': case 'd': case 'e':
+ case 'f': case 'g': case 'h': case 'i': case 'j':
+ case 'k': case 'l': case 'm': case 'n': case 'o':
+ case 'p': case 'q': case 'r': case 's': case 't':
+ case 'u': case 'v': case 'w': case 'x': case 'y':
+ case 'z': case '{': case '|': case '}': case '~':
+ /* c is in the ISO C "basic character set". */
+ ret = c32rtomb (buf, btoc32 (c), NULL);
+ ASSERT (ret == 1);
+ ASSERT (buf[0] == (char) c);
+ break;
+ }
/* Test special calling convention, passing a NULL pointer. */
{
if (argc > 1)
{
char32_t input[10];
- size_t n;
const char32_t *src;
#define BUFSIZE 20
char buf[BUFSIZE];
size_t ret;
- {
- size_t i;
- for (i = 0; i < BUFSIZE; i++)
- buf[i] = '_';
- }
+ for (size_t i = 0; i < BUFSIZE; i++)
+ buf[i] = '_';
switch (argv[1][0])
{
ret = mbstoc32s (input, original, 10);
ASSERT (ret == 5);
- for (n = 0; n < 10; n++)
+ for (size_t n = 0; n < 10; n++)
{
src = input;
ret = c32snrtombs (NULL, &src, 6, n, NULL);
ret = mbstoc32s (input, original, 10);
ASSERT (ret == 5);
- for (n = 0; n < 15; n++)
+ for (size_t n = 0; n < 15; n++)
{
src = input;
ret = c32snrtombs (NULL, &src, 6, n, NULL);
ret = mbstoc32s (input, original, 10);
ASSERT (ret == 5);
- for (n = 0; n < 10; n++)
+ for (size_t n = 0; n < 10; n++)
{
src = input;
ret = c32snrtombs (NULL, &src, 6, n, NULL);
ret = mbstoc32s (input, original, 10);
ASSERT (ret == 5);
- for (n = 0; n < 15; n++)
+ for (size_t n = 0; n < 15; n++)
{
src = input;
ret = c32snrtombs (NULL, &src, 6, n, NULL);
if (argc > 1)
{
char32_t input[10];
- size_t n;
const char32_t *src;
#define BUFSIZE 20
char buf[BUFSIZE];
size_t ret;
- {
- size_t i;
- for (i = 0; i < BUFSIZE; i++)
- buf[i] = '_';
- }
+ for (size_t i = 0; i < BUFSIZE; i++)
+ buf[i] = '_';
switch (argv[1][0])
{
ret = mbstoc32s (input, original, 10);
ASSERT (ret == 5);
- for (n = 0; n < 10; n++)
+ for (size_t n = 0; n < 10; n++)
{
src = input;
ret = c32srtombs (NULL, &src, n, NULL);
ret = mbstoc32s (input, original, 10);
ASSERT (ret == 5);
- for (n = 0; n < 15; n++)
+ for (size_t n = 0; n < 15; n++)
{
src = input;
ret = c32srtombs (NULL, &src, n, NULL);
ret = mbstoc32s (input, original, 10);
ASSERT (ret == 5);
- for (n = 0; n < 10; n++)
+ for (size_t n = 0; n < 10; n++)
{
src = input;
ret = c32srtombs (NULL, &src, n, NULL);
ret = mbstoc32s (input, original, 10);
ASSERT (ret == 5);
- for (n = 0; n < 15; n++)
+ for (size_t n = 0; n < 15; n++)
{
src = input;
ret = c32srtombs (NULL, &src, n, NULL);
if (argc > 1)
{
char32_t input[10];
- size_t n;
#define BUFSIZE 20
char buf[BUFSIZE];
size_t ret;
- {
- size_t i;
- for (i = 0; i < BUFSIZE; i++)
- buf[i] = '_';
- }
+ for (size_t i = 0; i < BUFSIZE; i++)
+ buf[i] = '_';
switch (argv[1][0])
{
ret = mbstoc32s (input, original, 10);
ASSERT (ret == 5);
- for (n = 0; n < 10; n++)
+ for (size_t n = 0; n < 10; n++)
{
ret = c32stombs (NULL, input, n);
ASSERT (ret == 5);
ret = mbstoc32s (input, original, 10);
ASSERT (ret == 5);
- for (n = 0; n < 15; n++)
+ for (size_t n = 0; n < 15; n++)
{
ret = c32stombs (NULL, input, n);
ASSERT (ret == 10);
ret = mbstoc32s (input, original, 10);
ASSERT (ret == 5);
- for (n = 0; n < 10; n++)
+ for (size_t n = 0; n < 10; n++)
{
ret = c32stombs (NULL, input, n);
ASSERT (ret == 8);
ret = mbstoc32s (input, original, 10);
ASSERT (ret == 5);
- for (n = 0; n < 15; n++)
+ for (size_t n = 0; n < 15; n++)
{
ret = c32stombs (NULL, input, n);
ASSERT (ret == 12);
See <https://gnats.netbsd.org/cgi-bin/query-pr-single.pl?number=57339>. */
if (!(argc > 1 && argv[1][0] == '4'))
#endif
- {
- int c;
-
- for (c = 0; c < 0x100; c++)
- switch (c)
- {
- case '\t': case '\v': case '\f':
- case ' ': case '!': case '"': case '#': case '%':
- case '&': case '\'': case '(': case ')': case '*':
- case '+': case ',': case '-': case '.': case '/':
- case '0': case '1': case '2': case '3': case '4':
- case '5': case '6': case '7': case '8': case '9':
- case ':': case ';': case '<': case '=': case '>':
- case '?':
- case 'A': case 'B': case 'C': case 'D': case 'E':
- case 'F': case 'G': case 'H': case 'I': case 'J':
- case 'K': case 'L': case 'M': case 'N': case 'O':
- case 'P': case 'Q': case 'R': case 'S': case 'T':
- case 'U': case 'V': case 'W': case 'X': case 'Y':
- case 'Z':
- case '[': case '\\': case ']': case '^': case '_':
- case 'a': case 'b': case 'c': case 'd': case 'e':
- case 'f': case 'g': case 'h': case 'i': case 'j':
- case 'k': case 'l': case 'm': case 'n': case 'o':
- case 'p': case 'q': case 'r': case 's': case 't':
- case 'u': case 'v': case 'w': case 'x': case 'y':
- case 'z': case '{': case '|': case '}': case '~':
- /* c is in the ISO C "basic character set". */
- buf[0] = (unsigned char) c;
- mb = for_character (buf, 1);
- switch (c)
- {
- case 'A': case 'B': case 'C': case 'D': case 'E':
- case 'F': case 'G': case 'H': case 'I': case 'J':
- case 'K': case 'L': case 'M': case 'N': case 'O':
- case 'P': case 'Q': case 'R': case 'S': case 'T':
- case 'U': case 'V': case 'W': case 'X': case 'Y':
- case 'Z':
- ASSERT (mb.nbytes == 1);
- ASSERT ((unsigned char) mb.buf[0] == (unsigned char) c - 'A' + 'a');
- break;
- default:
- ASSERT (mb.nbytes == 1);
- ASSERT ((unsigned char) mb.buf[0] == c);
- break;
- }
- break;
- }
- }
+ for (int c = 0; c < 0x100; c++)
+ switch (c)
+ {
+ case '\t': case '\v': case '\f':
+ case ' ': case '!': case '"': case '#': case '%':
+ case '&': case '\'': case '(': case ')': case '*':
+ case '+': case ',': case '-': case '.': case '/':
+ case '0': case '1': case '2': case '3': case '4':
+ case '5': case '6': case '7': case '8': case '9':
+ case ':': case ';': case '<': case '=': case '>':
+ case '?':
+ case 'A': case 'B': case 'C': case 'D': case 'E':
+ case 'F': case 'G': case 'H': case 'I': case 'J':
+ case 'K': case 'L': case 'M': case 'N': case 'O':
+ case 'P': case 'Q': case 'R': case 'S': case 'T':
+ case 'U': case 'V': case 'W': case 'X': case 'Y':
+ case 'Z':
+ case '[': case '\\': case ']': case '^': case '_':
+ case 'a': case 'b': case 'c': case 'd': case 'e':
+ case 'f': case 'g': case 'h': case 'i': case 'j':
+ case 'k': case 'l': case 'm': case 'n': case 'o':
+ case 'p': case 'q': case 'r': case 's': case 't':
+ case 'u': case 'v': case 'w': case 'x': case 'y':
+ case 'z': case '{': case '|': case '}': case '~':
+ /* c is in the ISO C "basic character set". */
+ buf[0] = (unsigned char) c;
+ mb = for_character (buf, 1);
+ switch (c)
+ {
+ case 'A': case 'B': case 'C': case 'D': case 'E':
+ case 'F': case 'G': case 'H': case 'I': case 'J':
+ case 'K': case 'L': case 'M': case 'N': case 'O':
+ case 'P': case 'Q': case 'R': case 'S': case 'T':
+ case 'U': case 'V': case 'W': case 'X': case 'Y':
+ case 'Z':
+ ASSERT (mb.nbytes == 1);
+ ASSERT ((unsigned char) mb.buf[0] == (unsigned char) c - 'A' + 'a');
+ break;
+ default:
+ ASSERT (mb.nbytes == 1);
+ ASSERT ((unsigned char) mb.buf[0] == c);
+ break;
+ }
+ break;
+ }
if (argc > 1)
switch (argv[1][0])
See <https://gnats.netbsd.org/cgi-bin/query-pr-single.pl?number=57339>. */
if (!(argc > 1 && argv[1][0] == '4'))
#endif
- {
- int c;
-
- for (c = 0; c < 0x100; c++)
- switch (c)
- {
- case '\t': case '\v': case '\f':
- case ' ': case '!': case '"': case '#': case '%':
- case '&': case '\'': case '(': case ')': case '*':
- case '+': case ',': case '-': case '.': case '/':
- case '0': case '1': case '2': case '3': case '4':
- case '5': case '6': case '7': case '8': case '9':
- case ':': case ';': case '<': case '=': case '>':
- case '?':
- case 'A': case 'B': case 'C': case 'D': case 'E':
- case 'F': case 'G': case 'H': case 'I': case 'J':
- case 'K': case 'L': case 'M': case 'N': case 'O':
- case 'P': case 'Q': case 'R': case 'S': case 'T':
- case 'U': case 'V': case 'W': case 'X': case 'Y':
- case 'Z':
- case '[': case '\\': case ']': case '^': case '_':
- case 'a': case 'b': case 'c': case 'd': case 'e':
- case 'f': case 'g': case 'h': case 'i': case 'j':
- case 'k': case 'l': case 'm': case 'n': case 'o':
- case 'p': case 'q': case 'r': case 's': case 't':
- case 'u': case 'v': case 'w': case 'x': case 'y':
- case 'z': case '{': case '|': case '}': case '~':
- /* c is in the ISO C "basic character set". */
- buf[0] = (unsigned char) c;
- mb = for_character (buf, 1);
- switch (c)
- {
- case 'a': case 'b': case 'c': case 'd': case 'e':
- case 'f': case 'g': case 'h': case 'i': case 'j':
- case 'k': case 'l': case 'm': case 'n': case 'o':
- case 'p': case 'q': case 'r': case 's': case 't':
- case 'u': case 'v': case 'w': case 'x': case 'y':
- case 'z':
- ASSERT (mb.nbytes == 1);
- ASSERT ((unsigned char) mb.buf[0] == (unsigned char) c - 'a' + 'A');
- break;
- default:
- ASSERT (mb.nbytes == 1);
- ASSERT ((unsigned char) mb.buf[0] == c);
- break;
- }
- break;
- }
- }
+ for (int c = 0; c < 0x100; c++)
+ switch (c)
+ {
+ case '\t': case '\v': case '\f':
+ case ' ': case '!': case '"': case '#': case '%':
+ case '&': case '\'': case '(': case ')': case '*':
+ case '+': case ',': case '-': case '.': case '/':
+ case '0': case '1': case '2': case '3': case '4':
+ case '5': case '6': case '7': case '8': case '9':
+ case ':': case ';': case '<': case '=': case '>':
+ case '?':
+ case 'A': case 'B': case 'C': case 'D': case 'E':
+ case 'F': case 'G': case 'H': case 'I': case 'J':
+ case 'K': case 'L': case 'M': case 'N': case 'O':
+ case 'P': case 'Q': case 'R': case 'S': case 'T':
+ case 'U': case 'V': case 'W': case 'X': case 'Y':
+ case 'Z':
+ case '[': case '\\': case ']': case '^': case '_':
+ case 'a': case 'b': case 'c': case 'd': case 'e':
+ case 'f': case 'g': case 'h': case 'i': case 'j':
+ case 'k': case 'l': case 'm': case 'n': case 'o':
+ case 'p': case 'q': case 'r': case 's': case 't':
+ case 'u': case 'v': case 'w': case 'x': case 'y':
+ case 'z': case '{': case '|': case '}': case '~':
+ /* c is in the ISO C "basic character set". */
+ buf[0] = (unsigned char) c;
+ mb = for_character (buf, 1);
+ switch (c)
+ {
+ case 'a': case 'b': case 'c': case 'd': case 'e':
+ case 'f': case 'g': case 'h': case 'i': case 'j':
+ case 'k': case 'l': case 'm': case 'n': case 'o':
+ case 'p': case 'q': case 'r': case 's': case 't':
+ case 'u': case 'v': case 'w': case 'x': case 'y':
+ case 'z':
+ ASSERT (mb.nbytes == 1);
+ ASSERT ((unsigned char) mb.buf[0] == (unsigned char) c - 'a' + 'A');
+ break;
+ default:
+ ASSERT (mb.nbytes == 1);
+ ASSERT ((unsigned char) mb.buf[0] == c);
+ break;
+ }
+ break;
+ }
if (argc > 1)
switch (argv[1][0])
int
main ()
{
- char32_t wc;
-
#if !GNULIB_WCHAR_SINGLE_LOCALE
# ifdef C_CTYPE_ASCII
/* Test width of ASCII characters. */
- for (wc = 0x20; wc < 0x7F; wc++)
+ for (char32_t wc = 0x20; wc < 0x7F; wc++)
ASSERT (c32width (wc) == 1);
# endif
#endif
&& strcmp (locale_charset (), "UTF-8") == 0)
{
/* Test width of ASCII characters. */
- for (wc = 0x20; wc < 0x7F; wc++)
+ for (char32_t wc = 0x20; wc < 0x7F; wc++)
ASSERT (c32width (wc) == 1);
/* Test width of some non-spacing characters. */
once_contender_thread (void *arg)
{
int id = (int) (intptr_t) arg;
- int repeat;
- for (repeat = 0; repeat <= REPEAT_COUNT; repeat++)
+ for (int repeat = 0; repeat <= REPEAT_COUNT; repeat++)
{
/* Tell the main thread that we're ready. */
ASSERT (mtx_lock (&ready_lock[id]) == thrd_success);
static void
test_once (void)
{
- int i, repeat;
thrd_t threads[THREAD_COUNT];
/* Initialize all variables. */
- for (i = 0; i < THREAD_COUNT; i++)
+ for (int i = 0; i < THREAD_COUNT; i++)
{
ready[i] = 0;
ASSERT (mtx_init (&ready_lock[i], mtx_plain) == thrd_success);
}
#if ENABLE_LOCKING
- for (i = 0; i < REPEAT_COUNT; i++)
+ for (int i = 0; i < REPEAT_COUNT; i++)
gl_rwlock_init (fire_signal[i]);
#else
fire_signal_state = 0;
#if ENABLE_LOCKING
/* Block all fire_signals. */
- for (i = REPEAT_COUNT-1; i >= 0; i--)
+ for (int i = REPEAT_COUNT-1; i >= 0; i--)
gl_rwlock_wrlock (fire_signal[i]);
#endif
/* Spawn the threads. */
- for (i = 0; i < THREAD_COUNT; i++)
+ for (int i = 0; i < THREAD_COUNT; i++)
ASSERT (thrd_create (&threads[i],
once_contender_thread, (void *) (intptr_t) i)
== thrd_success);
- for (repeat = 0; repeat <= REPEAT_COUNT; repeat++)
+ for (int repeat = 0; repeat <= REPEAT_COUNT; repeat++)
{
/* Wait until every thread is ready. */
dbgprintf ("Main thread before synchronizing for round %d\n", repeat);
for (;;)
{
int ready_count = 0;
- for (i = 0; i < THREAD_COUNT; i++)
+ for (int i = 0; i < THREAD_COUNT; i++)
{
ASSERT (mtx_lock (&ready_lock[i]) == thrd_success);
ready_count += ready[i];
performed = 0;
/* Preparation for the next round: Reset the ready flags. */
- for (i = 0; i < THREAD_COUNT; i++)
+ for (int i = 0; i < THREAD_COUNT; i++)
{
ASSERT (mtx_lock (&ready_lock[i]) == thrd_success);
ready[i] = 0;
}
/* Wait for the threads to terminate. */
- for (i = 0; i < THREAD_COUNT; i++)
+ for (int i = 0; i < THREAD_COUNT; i++)
ASSERT (thrd_join (threads[i], NULL) == thrd_success);
}
static void
check_equals (gl_list_t list1, gl_list_t list2)
{
- size_t n, i;
+ size_t n;
n = gl_list_size (list1);
ASSERT (n == gl_list_size (list2));
- for (i = 0; i < n; i++)
+ for (size_t i = 0; i < n; i++)
{
ASSERT (gl_list_get_at (list1, i) == gl_list_get_at (list2, i));
}
size_t initial_size = RANDOM (50);
const void **contents =
(const void **) malloc (initial_size * sizeof (const void *));
- size_t i;
- unsigned int repeat;
- for (i = 0; i < initial_size; i++)
+ for (size_t i = 0; i < initial_size; i++)
contents[i] = RANDOM_OBJECT ();
/* Create list1. */
/* Create list2. */
list2 = gl_list_nx_create_empty (GL_CARRAY_LIST, NULL, NULL, NULL, true);
ASSERT (list2 != NULL);
- for (i = 0; i < initial_size; i++)
+ for (size_t i = 0; i < initial_size; i++)
ASSERT (gl_list_nx_add_last (list2, contents[i]) != NULL);
/* Create list3. */
check_equals_by_forward_iteration (list1, list2);
check_equals_by_backward_iteration (list1, list2);
- for (repeat = 0; repeat < 10000; repeat++)
+ for (unsigned int repeat = 0; repeat < 10000; repeat++)
{
unsigned int operation = RANDOM (18);
switch (operation)
iter1 = gl_list_iterator (list1);
iter2 = gl_list_iterator (list2);
iter3 = gl_list_iterator (list3);
- for (i = 0; i < n; i++)
+ for (size_t i = 0; i < n; i++)
{
ASSERT (gl_list_iterator_next (&iter1, &elt, NULL));
ASSERT (gl_list_get_at (list1, i) == elt);
iter1 = gl_list_iterator_from_to (list1, start, end);
iter2 = gl_list_iterator_from_to (list2, start, end);
iter3 = gl_list_iterator_from_to (list3, start, end);
- for (i = start; i < end; i++)
+ for (size_t i = start; i < end; i++)
{
ASSERT (gl_list_iterator_next (&iter1, &elt, NULL));
ASSERT (gl_list_get_at (list1, i) == elt);
static void
test_function (void)
{
- int i;
- int j;
const DOUBLE TWO_MANT_DIG =
/* Assume MANT_DIG <= 5 * 31.
Use the identity
* (DOUBLE) (1U << ((MANT_DIG - 1 + 4) / 5));
/* Randomized tests. */
- for (i = 0; i < SIZEOF (RANDOM); i++)
+ for (int i = 0; i < SIZEOF (RANDOM); i++)
{
DOUBLE x = L_(32.0) * RANDOM[i] - L_(16.0); /* -16.0 <= x <= 16.0 */
DOUBLE y = CBRT (x);
&& err < L_(4.0) * L_(16.0) / TWO_MANT_DIG);
}
- for (i = 0; i < SIZEOF (RANDOM) / 5; i++)
- for (j = 0; j < SIZEOF (RANDOM) / 5; j++)
+ for (int i = 0; i < SIZEOF (RANDOM) / 5; i++)
+ for (int j = 0; j < SIZEOF (RANDOM) / 5; j++)
{
DOUBLE x = L_(32.0) * RANDOM[i] - L_(16.0); /* -16.0 <= x <= 16.0 */
DOUBLE y = L_(32.0) * RANDOM[j] - L_(16.0); /* -16.0 <= y <= 16.0 */
int
main ()
{
- unsigned int highbits;
- unsigned int lowbits;
int error = 0;
- for (highbits = 0; highbits < (1 << NUM_HIGHBITS); highbits++)
- for (lowbits = 0; lowbits < (1 << NUM_LOWBITS); lowbits++)
+ for (unsigned int highbits = 0; highbits < (1 << NUM_HIGHBITS); highbits++)
+ for (unsigned int lowbits = 0; lowbits < (1 << NUM_LOWBITS); lowbits++)
{
/* Combine highbits and lowbits into a floating-point number,
sign-extending the lowbits to 64-NUM_HIGHBITS bits. */
int
main ()
{
- unsigned int highbits;
- unsigned int lowbits;
int error = 0;
- for (highbits = 0; highbits < (1 << NUM_HIGHBITS); highbits++)
- for (lowbits = 0; lowbits < (1 << NUM_LOWBITS); lowbits++)
+ for (unsigned int highbits = 0; highbits < (1 << NUM_HIGHBITS); highbits++)
+ for (unsigned int lowbits = 0; lowbits < (1 << NUM_LOWBITS); lowbits++)
{
/* Combine highbits and lowbits into a floating-point number,
sign-extending the lowbits to 32-NUM_HIGHBITS bits. */
int
main (int argc, char *argv[])
{
- int i, j;
-
#define TEST_COUNT_LEADING_ZEROS(FUNC, TYPE, BITS, MAX, ONE) \
ASSERT (FUNC (0) == BITS); \
- for (i = 0; i < BITS; i++) \
+ for (int i = 0; i < BITS; i++) \
{ \
ASSERT (FUNC (ONE << i) == BITS - i - 1); \
- for (j = 0; j < i; j++) \
+ for (int j = 0; j < i; j++) \
ASSERT (FUNC ((ONE << i) | (ONE << j)) == BITS - i - 1); \
} \
- for (i = 0; i < 1000; i++) \
+ for (int i = 0; i < 1000; i++) \
{ \
/* RAND_MAX is most often 0x7fff or 0x7fffffff. */ \
TYPE value = \
^ (((TYPE) rand () >> 3) << 22) \
^ (((TYPE) rand () >> 3) << 22 << 22)); \
int count = 0; \
- for (j = 0; j < BITS; j++) \
+ for (int j = 0; j < BITS; j++) \
if (value & (ONE << j)) \
count = BITS - j - 1; \
ASSERT (count == FUNC (value)); \
int
main (int argc, char *argv[])
{
- int i, j;
-
#define TEST_COUNT_ONE_BITS(FUNC, TYPE, BITS, MAX, ONE) \
ASSERT (FUNC (0) == 0); \
- for (i = 0; i < BITS; i++) \
+ for (int i = 0; i < BITS; i++) \
{ \
ASSERT (FUNC (ONE << i) == 1); \
- for (j = i + 1; j < BITS; j++) \
+ for (int j = i + 1; j < BITS; j++) \
ASSERT (FUNC ((ONE << i) | (ONE << j)) == 2); \
} \
- for (i = 0; i < 1000; i++) \
+ for (int i = 0; i < 1000; i++) \
{ \
/* RAND_MAX is most often 0x7fff or 0x7fffffff. */ \
TYPE value = \
^ (((TYPE) rand () >> 3) << 22) \
^ (((TYPE) rand () >> 3) << 22 << 22)); \
int count = 0; \
- for (j = 0; j < BITS; j++) \
+ for (int j = 0; j < BITS; j++) \
count += (value & (ONE << j)) != 0; \
ASSERT (count == FUNC (value)); \
} \
int
main (int argc, char *argv[])
{
- int i, j;
-
#define TEST_COUNT_TRAILING_ZEROS(FUNC, TYPE, BITS, MAX, ONE) \
ASSERT (FUNC (0) == BITS); \
- for (i = 0; i < BITS; i++) \
+ for (int i = 0; i < BITS; i++) \
{ \
ASSERT (FUNC (ONE << i) == i); \
- for (j = 0; j < i; j++) \
+ for (int j = 0; j < i; j++) \
ASSERT (FUNC ((ONE << i) | (ONE << j)) == j); \
} \
- for (i = 0; i < 1000; i++) \
+ for (int i = 0; i < 1000; i++) \
{ \
/* RAND_MAX is most often 0x7fff or 0x7fffffff. */ \
TYPE value = \
^ (((TYPE) rand () >> 3) << 22) \
^ (((TYPE) rand () >> 3) << 22 << 22)); \
int count = 0; \
- for (j = BITS - 1; 0 <= j; j--) \
+ for (int j = BITS - 1; 0 <= j; j--) \
if (value & (ONE << j)) \
count = j; \
ASSERT (count == FUNC (value)); \
main (void)
{
uint32_t p;
- size_t i, j;
char data[MAX_ALIGNMENT * 3];
p = crc32_update_no_xor (42, "foo", 3);
/* Test for trailing unaligned bytes */
- for (i = 0; i < MAX_ALIGNMENT; i++)
+ for (size_t i = 0; i < MAX_ALIGNMENT; i++)
{
p = crc32_update_no_xor (0, randomb, MAX_ALIGNMENT + i);
if (p != trailing_unaligned_byte_hashes[i])
/* Test for leading unaligned bytes */
- for (i = 0; i < MAX_ALIGNMENT; i++)
+ for (size_t i = 0; i < MAX_ALIGNMENT; i++)
{
p = crc32_update_no_xor (0, randomb + i, (MAX_ALIGNMENT * 2) - i);
if (p != leading_unaligned_byte_hashes[i])
/* Combined test of multiple lengths at multiple alignments */
- for (i = 0; i < MAX_ALIGNMENT; i++)
- for (j = 0; j < MAX_ALIGNMENT; j++)
+ for (size_t i = 0; i < MAX_ALIGNMENT; i++)
+ for (size_t j = 0; j < MAX_ALIGNMENT; j++)
{
memcpy (data + i, randomb, MAX_ALIGNMENT * 2);
p = crc32_update_no_xor (0, data + i, j);
* DES Maintenance Test
*/
{
- int i;
char key[8] = { 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55 };
char input[8] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
char result[8] = { 0x24, 0x6e, 0x9d, 0xb9, 0xc5, 0x50, 0x38, 0x1a };
char temp1[8], temp2[8], temp3[8];
gl_des_ctx des;
- for (i = 0; i < 64; ++i)
+ for (int i = 0; i < 64; ++i)
{
gl_des_setkey (&des, key);
gl_des_ecb_encrypt (&des, input, temp1);
* Self made Triple-DES test (Does somebody know an official test?)
*/
{
- int i;
char input[8] = { 0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10 };
char key1[8] = { 0x12, 0x34, 0x56, 0x78, 0x9a, 0xbc, 0xde, 0xf0 };
char key2[8] = { 0x11, 0x22, 0x33, 0x44, 0xff, 0xaa, 0xcc, 0xdd };
gl_3des_ctx des3;
- for (i = 0; i < 16; ++i)
+ for (int i = 0; i < 16; ++i)
{
gl_3des_set2keys (&des3, key1, key2);
gl_3des_ecb_encrypt (&des3, input, key1);
};
char result[8];
- int i;
gl_3des_ctx des3;
- for (i = 0; i < sizeof (testdata) / sizeof (*testdata); ++i)
+ for (int i = 0; i < sizeof (testdata) / sizeof (*testdata); ++i)
{
gl_3des_set3keys (&des3, testdata[i].key,
testdata[i].key + 8, testdata[i].key + 16);
ASSERT (di_set_insert (dis, 5, (ino_t) -1) == 1);
ASSERT (di_set_insert (dis, 5, (ino_t) -1) == 0); /* dup */
- {
- unsigned int i;
- for (i = 0; i < 3000; i++)
- ASSERT (di_set_insert (dis, 9, i) == 1);
- for (i = 0; i < 3000; i++)
- ASSERT (di_set_insert (dis, 9, i) == 0); /* duplicate fails */
- }
+ for (unsigned int i = 0; i < 3000; i++)
+ ASSERT (di_set_insert (dis, 9, i) == 1);
+ for (unsigned int i = 0; i < 3000; i++)
+ ASSERT (di_set_insert (dis, 9, i) == 0); /* duplicate fails */
di_set_free (dis);
const void *expected_for_small_file,
const void *expected_for_large_file)
{
- int pass;
unlink (TESTFILE);
- for (pass = 0; pass < 5; pass++)
+ for (int pass = 0; pass < 5; pass++)
{
{
FILE *fp = fopen (TESTFILE, "wb");
FALLTHROUGH;
case 3:
/* Fill the large file (8 MiB). */
- {
- unsigned int i;
- for (i = 0; i < 0x400000; i++)
- {
- unsigned char c[2];
- unsigned int j = i * (i-1) * (i-5);
- c[0] = (unsigned char)(j >> 6);
- c[1] = (i % 499) + (i % 101);
- fwrite (c, 1, 2, fp);
- }
- }
+ for (unsigned int i = 0; i < 0x400000; i++)
+ {
+ unsigned char c[2];
+ unsigned int j = i * (i-1) * (i-5);
+ c[0] = (unsigned char)(j >> 6);
+ c[1] = (i % 499) + (i % 101);
+ fwrite (c, 1, 2, fp);
+ }
break;
}
if (ferror (fp))
}
if (memcmp (digest, expected, digest_size) != 0)
{
- size_t i;
fprintf (stderr, "%s produced wrong result.\n", streamfunc_name);
fprintf (stderr, "Expected: ");
- for (i = 0; i < digest_size; i++)
+ for (size_t i = 0; i < digest_size; i++)
fprintf (stderr, "\\x%02x", ((const unsigned char *) expected)[i]);
fprintf (stderr, "\n");
fprintf (stderr, "Got: ");
- for (i = 0; i < digest_size; i++)
+ for (size_t i = 0; i < digest_size; i++)
fprintf (stderr, "\\x%02x", ((const unsigned char *) digest)[i]);
fprintf (stderr, "\n");
exit (1);
int
main (void)
{
- int i;
DIR *dp;
/* The dirent-safer module works without the use of fdopendir (which
would also pull in fchdir and openat); but if those modules were
/* Four iterations, with progressively more standard descriptors
closed. */
- for (i = -1; i <= STDERR_FILENO; i++)
+ for (int i = -1; i <= STDERR_FILENO; i++)
{
if (0 <= i)
ASSERT (close (i) == 0);
int
main (void)
{
- struct test *t;
bool ok = true;
- for (t = tests; t->name; t++)
+ for (struct test *t = tests; t->name; t++)
{
char *dir = dir_name (t->name);
int dirlen = dir_len (t->name);
{
/* Perform the test and test whether it triggers a permanent memory
allocation of more than MAX_ALLOC_TOTAL bytes. */
- int repeat;
- for (repeat = 0; repeat < NUM_ROUNDS; repeat++)
+ for (int repeat = 0; repeat < NUM_ROUNDS; repeat++)
{
/* This may produce a temporary memory allocation of 11000 bytes.
but should not result in a permanent memory allocation. */
int
main (void)
{
- int i;
int fd;
int bad_fd = getdtablesize ();
/* Four iterations, with progressively more standard descriptors
closed. */
- for (i = -1; i <= STDERR_FILENO; i++)
+ for (int i = -1; i <= STDERR_FILENO; i++)
{
if (0 <= i)
ASSERT (close (i) == 0);
int
main ()
{
- int use_cloexec;
int bad_fd = getdtablesize ();
#if O_CLOEXEC
- for (use_cloexec = 0; use_cloexec <= 1; use_cloexec++)
+ for (int use_cloexec = 0; use_cloexec <= 1; use_cloexec++)
#else
- use_cloexec = 0;
+ int use_cloexec = 0;
#endif
{
const char *file = "test-dup3.tmp";
main ()
{
struct int_sequence s;
- int i;
intseq_init (&s);
- for (i = 0; i < N; i++)
+ for (int i = 0; i < N; i++)
intseq_add (&s, value_at (i));
- for (i = N - 1; i >= N / 2; i--)
+ for (int i = N - 1; i >= N / 2; i--)
{
ASSERT (* intseq_at (&s, i) == value_at (i));
intseq_remove_last (&s);
main (int argc, char* argv[])
{
/* Print the arguments. */
- int i;
printf ("argc = %d\n", argc);
- for (i = 1; i < argc; i++)
+ for (int i = 1; i < argc; i++)
printf ("argv[%d] = |%s|\n", i, argv[i]);
/* Print a particular environment variable. */
get_environ_assignment (const char *name)
{
size_t name_len = strlen (name);
- char **p;
- for (p = environ; *p != NULL; p++)
+ for (char **p = environ; *p != NULL; p++)
{
const char *assignment = *p;
if (strncmp (assignment, name, name_len) == 0
char buf[300];
buf[0] = '\0';
char *p = buf;
- int fd;
- for (fd = 0; fd < 20; fd++)
+ for (int fd = 0; fd < 20; fd++)
if (is_open (fd) && !(is_qemu && fd == 3))
{
sprintf (p, "%d ", fd);
#if HAVE_CLOSE_RANGE
if (close_range (3, 20 - 1, 0) < 0)
#endif
- {
- int fd;
- for (fd = 3; fd < 20; fd++)
- close (fd);
- }
+ for (int fd = 3; fd < 20; fd++)
+ close (fd);
break;
default:
break;
FILE *fp = freopen (DATA_FILENAME, "w", stdout);
ASSERT (fp != NULL);
- {
- size_t i;
-
- for (i = 0; i < 2; i++)
- {
- const char *progname =
- (i == 0 ? "executable-script" : "executable-script.sh");
- const char *prog_path =
- (i == 0 ? SRCDIR "executable-script" : SRCDIR "executable-script.sh");
- const char *prog_argv[2] = { prog_path, NULL };
-
- int ret = execute (progname, prog_argv[0], prog_argv, NULL, NULL,
- false, false, false, false, true, false, NULL);
- ASSERT (ret == 127);
- }
- }
+ for (size_t i = 0; i < 2; i++)
+ {
+ const char *progname =
+ (i == 0 ? "executable-script" : "executable-script.sh");
+ const char *prog_path =
+ (i == 0 ? SRCDIR "executable-script" : SRCDIR "executable-script.sh");
+ const char *prog_argv[2] = { prog_path, NULL };
+
+ int ret = execute (progname, prog_argv[0], prog_argv, NULL, NULL,
+ false, false, false, false, true, false, NULL);
+ ASSERT (ret == 127);
+ }
#if defined _WIN32 && !defined __CYGWIN__
/* On native Windows, scripts - even with '#!' marker - are not executable.
get_environ_assignment (const char *name)
{
size_t name_len = strlen (name);
- char **p;
- for (p = environ; *p != NULL; p++)
+ for (char **p = environ; *p != NULL; p++)
{
const char *assignment = *p;
if (strncmp (assignment, name, name_len) == 0
get_environ_assignment (const char *name)
{
size_t name_len = strlen (name);
- char **p;
- for (p = environ; *p != NULL; p++)
+ for (char **p = environ; *p != NULL; p++)
{
const char *assignment = *p;
if (strncmp (assignment, name, name_len) == 0
static void
test_function (void)
{
- int i;
- int j;
const DOUBLE TWO_MANT_DIG =
/* Assume MANT_DIG <= 5 * 31.
Use the identity
#endif
: L_(2.0));
- for (i = 0; i < SIZEOF (RANDOM); i++)
+ for (int i = 0; i < SIZEOF (RANDOM); i++)
{
DOUBLE x = L_(16.0) * RANDOM[i]; /* 0.0 <= x <= 16.0 */
DOUBLE y = EXP (x);
#endif
: L_(24.0));
- for (i = 0; i < SIZEOF (RANDOM) / 5; i++)
- for (j = 0; j < SIZEOF (RANDOM) / 5; j++)
+ for (int i = 0; i < SIZEOF (RANDOM) / 5; i++)
+ for (int j = 0; j < SIZEOF (RANDOM) / 5; j++)
{
DOUBLE x = L_(32.0) * RANDOM[i] - L_(16.0); /* -16.0 <= x <= 16.0 */
DOUBLE y = L_(32.0) * RANDOM[j] - L_(16.0); /* -16.0 <= y <= 16.0 */
static void
test_function (void)
{
- int i;
- int j;
const DOUBLE TWO_MANT_DIG =
/* Assume MANT_DIG <= 5 * 31.
Use the identity
#endif
: L_(3.0));
- for (i = 0; i < SIZEOF (RANDOM); i++)
+ for (int i = 0; i < SIZEOF (RANDOM); i++)
{
DOUBLE x = L_(16.0) * RANDOM[i]; /* 0.0 <= x <= 16.0 */
DOUBLE y = EXP2 (x);
#endif
: L_(11.0));
- for (i = 0; i < SIZEOF (RANDOM) / 5; i++)
- for (j = 0; j < SIZEOF (RANDOM) / 5; j++)
+ for (int i = 0; i < SIZEOF (RANDOM) / 5; i++)
+ for (int j = 0; j < SIZEOF (RANDOM) / 5; j++)
{
DOUBLE x = L_(32.0) * RANDOM[i] - L_(16.0); /* -16.0 <= x <= 16.0 */
DOUBLE y = L_(32.0) * RANDOM[j] - L_(16.0); /* -16.0 <= y <= 16.0 */
test_stack (void)
{
int count = 0;
- int repeat;
char *volatile last_stackbuf;
- for (repeat = 2 * 1000; repeat > 0; repeat--)
+ for (int repeat = 2 * 1000; repeat > 0; repeat--)
{
/* This odd way of writing two consecutive statements
do_secret_stuff (1, &last_stackbuf);
static void
test_function (void)
{
- int i;
- int j;
const DOUBLE TWO_MANT_DIG =
/* Assume MANT_DIG <= 5 * 31.
Use the identity
/* Arguments near zero. */
{
+ int i;
DOUBLE x;
for (i = -1, x = L_(0.5); i >= MIN_EXP; i--, x *= L_(0.5))
#endif
: L_(5.0));
- for (i = 0; i < SIZEOF (RANDOM); i++)
+ for (int i = 0; i < SIZEOF (RANDOM); i++)
{
DOUBLE x = L_(2.0) * RANDOM[i]; /* 0.0 <= x <= 2.0 */
DOUBLE y = EXPM1 (x);
#endif
: L_(9.0));
- for (i = 0; i < SIZEOF (RANDOM) / 5; i++)
- for (j = 0; j < SIZEOF (RANDOM) / 5; j++)
+ for (int i = 0; i < SIZEOF (RANDOM) / 5; i++)
+ for (int j = 0; j < SIZEOF (RANDOM) / 5; j++)
{
DOUBLE x = L_(2.0) * RANDOM[i] - L_(1.0); /* -1.0 <= x <= 1.0 */
DOUBLE y = L_(2.0) * RANDOM[j] - L_(1.0); /* -1.0 <= y <= 1.0 */
ASSERT (!signbit (y));
/* Randomized tests. */
- {
- int i;
-
- for (i = 0; i < SIZEOF (RANDOM); i++)
- {
- x = L_(10.0) * RANDOM[i]; /* 0.0 <= x <= 10.0 */
- ASSERT (FABS (x) == x);
- ASSERT (FABS (- x) == x);
- }
- }
+ for (int i = 0; i < SIZEOF (RANDOM); i++)
+ {
+ x = L_(10.0) * RANDOM[i]; /* 0.0 <= x <= 10.0 */
+ ASSERT (FABS (x) == x);
+ ASSERT (FABS (- x) == x);
+ }
}
volatile DOUBLE x;
{
char *cwd;
int fd;
- int i;
cwd = getcwd (NULL, 0);
ASSERT (cwd);
}
/* Repeat test twice, once in '.' and once in '..'. */
- for (i = 0; i < 2; i++)
+ for (int i = 0; i < 2; i++)
{
ASSERT (chdir (&".."[1 - i]) == 0);
ASSERT (fchdir (fd) == 0);
int
main (void)
{
- int fd;
const char *file = "test-fdatasync.txt";
/* Assuming stdin and stdout are ttys, fdatasync is allowed to fail, but
may succeed as an extension. */
- for (fd = 0; fd < 2; fd++)
+ for (int fd = 0; fd < 2; fd++)
if (fdatasync (fd) != 0)
{
ASSERT (errno == EINVAL /* POSIX */
}
#endif
- fd = open (file, O_WRONLY|O_CREAT|O_TRUNC, 0644);
- ASSERT (0 <= fd);
- ASSERT (write (fd, "hello", 5) == 5);
- ASSERT (fdatasync (fd) == 0);
- ASSERT (close (fd) == 0);
+ {
+ int fd = open (file, O_WRONLY|O_CREAT|O_TRUNC, 0644);
+ ASSERT (0 <= fd);
+ ASSERT (write (fd, "hello", 5) == 5);
+ ASSERT (fdatasync (fd) == 0);
+ ASSERT (close (fd) == 0);
+ }
#if 0
/* POSIX is self-contradictory on whether fdatasync must fail on
read-only file descriptors. Glibc allows it, as does our
implementation if fsync allows it. */
- fd = open (file, O_RDONLY);
- ASSERT (0 <= fd);
- errno = 0;
- ASSERT (fdatasync (fd) == -1);
- ASSERT (errno == EBADF);
- ASSERT (close (fd) == 0);
+ {
+ int fd = open (file, O_RDONLY);
+ ASSERT (0 <= fd);
+ errno = 0;
+ ASSERT (fdatasync (fd) == -1);
+ ASSERT (errno == EBADF);
+ ASSERT (close (fd) == 0);
+ }
#endif
ASSERT (unlink (file) == 0);
#define COUNT 1000
#endif
- int i;
- for (i = 0; i < COUNT; i++)
+ for (int i = 0; i < COUNT; i++)
{
errno = 0;
if (! fdopen (STDOUT_FILENO, "w"))
int
main ()
{
- unsigned int a, b;
-
/* Run through all possible valid arguments to feenableexcept and
fedisableexcept.
An alternative way of coding this iteration, without the uint_to_exceptions
function, would be using the trick from
Jörg Arndt: Matters Computational <https://www.jjj.de/fxt/fxtbook.pdf>
§ 1.25.1 Generating bit subsets of a given word */
- for (a = 0; a < 0x20; a++)
- for (b = 0; b < 0x20; b++)
+ for (unsigned int a = 0; a < 0x20; a++)
+ for (unsigned int b = 0; b < 0x20; b++)
{
unsigned int c = a & ~b;
static int
naive (int i)
{
- unsigned int j;
- for (j = 0; j < NBITS; j++)
+ for (unsigned int j = 0; j < NBITS; j++)
if (i & (1U << j))
return j + 1;
return 0;
int
main (int argc, char *argv[])
{
- int x;
- int i;
-
- for (x = -128; x <= 128; x++)
+ for (int x = -128; x <= 128; x++)
ASSERT (ffs (x) == naive (x));
- for (i = 0; i < NBITS; i++)
+ for (int i = 0; i < NBITS; i++)
{
ASSERT (ffs (1U << i) == naive (1U << i));
ASSERT (ffs (1U << i) == i + 1);
ASSERT (ffs (-1U << i) == i + 1);
}
- for (i = 0; i < NBITS - 1; i++)
+ for (int i = 0; i < NBITS - 1; i++)
{
ASSERT (ffs (3U << i) == i + 1);
ASSERT (ffs (-3U << i) == i + 1);
}
- for (i = 0; i < NBITS - 2; i++)
+ for (int i = 0; i < NBITS - 2; i++)
{
ASSERT (ffs (5U << i) == i + 1);
ASSERT (ffs (-5U << i) == i + 1);
static int
naive (long int i)
{
- unsigned long int j;
- for (j = 0; j < NBITS; j++)
+ for (unsigned long int j = 0; j < NBITS; j++)
if (i & (1UL << j))
return j + 1;
return 0;
int
main (int argc, char *argv[])
{
- long int x;
- int i;
-
- for (x = -128; x <= 128; x++)
+ for (long int x = -128; x <= 128; x++)
ASSERT (ffsl (x) == naive (x));
- for (i = 0; i < NBITS; i++)
+ for (int i = 0; i < NBITS; i++)
{
ASSERT (ffsl (1UL << i) == naive (1UL << i));
ASSERT (ffsl (1UL << i) == i + 1);
ASSERT (ffsl (-1UL << i) == i + 1);
}
- for (i = 0; i < NBITS - 1; i++)
+ for (int i = 0; i < NBITS - 1; i++)
{
ASSERT (ffsl (3UL << i) == i + 1);
ASSERT (ffsl (-3UL << i) == i + 1);
}
- for (i = 0; i < NBITS - 2; i++)
+ for (int i = 0; i < NBITS - 2; i++)
{
ASSERT (ffsl (5UL << i) == i + 1);
ASSERT (ffsl (-5UL << i) == i + 1);
static int
naive (long long int i)
{
- unsigned long long int j;
- for (j = 0; j < NBITS; j++)
+ for (unsigned long long int j = 0; j < NBITS; j++)
if (i & (1ULL << j))
return j + 1;
return 0;
int
main (int argc, char *argv[])
{
- long long int x;
- int i;
-
- for (x = -128; x <= 128; x++)
+ for (long long int x = -128; x <= 128; x++)
ASSERT (ffsll (x) == naive (x));
- for (i = 0; i < NBITS; i++)
+ for (int i = 0; i < NBITS; i++)
{
ASSERT (ffsll (1ULL << i) == naive (1ULL << i));
ASSERT (ffsll (1ULL << i) == i + 1);
ASSERT (ffsll (-1ULL << i) == i + 1);
}
- for (i = 0; i < NBITS - 1; i++)
+ for (int i = 0; i < NBITS - 1; i++)
{
ASSERT (ffsll (3ULL << i) == i + 1);
ASSERT (ffsll (-3ULL << i) == i + 1);
}
- for (i = 0; i < NBITS - 2; i++)
+ for (int i = 0; i < NBITS - 2; i++)
{
ASSERT (ffsll (5ULL << i) == i + 1);
ASSERT (ffsll (-5ULL << i) == i + 1);
int
main (void)
{
- size_t i;
char buffer[12];
- for (i = 0; i < SIZEOF (table); ++i)
+ for (size_t i = 0; i < SIZEOF (table); ++i)
{
strmode (table[i].mode, buffer);
ASSERT (STREQ (table[i].str, buffer));
{"a", "//b", "a//b"},
{"", "a", "a"}, /* this might deserve a diagnostic */
};
- unsigned int i;
bool fail = false;
- for (i = 0; i < sizeof tests / sizeof tests[0]; i++)
+ for (unsigned int i = 0; i < sizeof tests / sizeof tests[0]; i++)
{
char *base_in_result;
char const *const *t = tests[i];
int
main (void)
{
- const char *const *i;
-
/* Following tests taken from test-strverscmp.c */
ASSERT (filevercmp ("", "") == 0);
ASSERT (filevercmp ("a", "a") == 0);
ASSERT (filevercmp ("0a", "0") > 0);
/* compare each version string with each other - O(n^2) */
- for (i = examples; *i; i++)
+ for (const char * const *i = examples; *i; i++)
{
- const char *const *j;
- for (j = examples; *j; j++)
+ for (const char * const *j = examples; *j; j++)
{
int result = test_filevercmp (*i, *j);
if (result < 0)
}
}
- for (i = equals; i < equals + sizeof equals / sizeof *equals; i++)
+ for (const char * const *i = equals; i < equals + sizeof equals / sizeof *equals; i++)
for (; *i; i++)
for (char const *const *j = i; *j; j++)
{
/* Check the value of FLT_MAX. */
{
volatile float m = FLT_MAX;
- int n;
ASSERT (m + m > m);
- for (n = 0; n <= 2 * FLT_MANT_DIG; n++)
+ for (int n = 0; n <= 2 * FLT_MANT_DIG; n++)
{
volatile float pow2_n = pow2f (n); /* 2^n */
volatile float x = m + (m / pow2_n);
{
volatile float e = FLT_EPSILON;
volatile float me;
- int n;
me = 1.0f + e;
ASSERT (me > 1.0f);
ASSERT (me - 1.0f == e);
- for (n = 0; n <= 2 * FLT_MANT_DIG; n++)
+ for (int n = 0; n <= 2 * FLT_MANT_DIG; n++)
{
volatile float half_n = pow2f (- n); /* 2^-n */
volatile float x = me - half_n;
/* Check the value of DBL_MAX. */
{
volatile double m = DBL_MAX;
- int n;
ASSERT (m + m > m);
- for (n = 0; n <= 2 * DBL_MANT_DIG; n++)
+ for (int n = 0; n <= 2 * DBL_MANT_DIG; n++)
{
volatile double pow2_n = pow2d (n); /* 2^n */
volatile double x = m + (m / pow2_n);
{
volatile double e = DBL_EPSILON;
volatile double me;
- int n;
me = 1.0 + e;
ASSERT (me > 1.0);
ASSERT (me - 1.0 == e);
- for (n = 0; n <= 2 * DBL_MANT_DIG; n++)
+ for (int n = 0; n <= 2 * DBL_MANT_DIG; n++)
{
volatile double half_n = pow2d (- n); /* 2^-n */
volatile double x = me - half_n;
if (LDBL_IS_IEC_60559)
{
volatile long double m = LDBL_MAX;
- int n;
ASSERT (m + m > m);
- for (n = 0; n <= 2 * LDBL_MANT_DIG; n++)
+ for (int n = 0; n <= 2 * LDBL_MANT_DIG; n++)
{
volatile long double pow2_n = pow2l (n); /* 2^n */
volatile long double x = m + (m / pow2_n);
{
volatile long double e = LDBL_EPSILON;
volatile long double me;
- int n;
me = 1.0L + e;
ASSERT (me > 1.0L);
ASSERT (me - 1.0L == e);
- for (n = 0; n <= 2 * LDBL_MANT_DIG; n++)
+ for (int n = 0; n <= 2 * LDBL_MANT_DIG; n++)
{
volatile long double half_n = pow2l (- n); /* 2^-n */
volatile long double x = normalize_long_double (me - half_n);
main ()
{
#ifdef UINT64_MAX
- unsigned int highbits;
- unsigned int lowbits;
int error = 0;
- for (highbits = 0; highbits < (1 << NUM_HIGHBITS); highbits++)
- for (lowbits = 0; lowbits < (1 << NUM_LOWBITS); lowbits++)
+ for (unsigned int highbits = 0; highbits < (1 << NUM_HIGHBITS); highbits++)
+ for (unsigned int lowbits = 0; lowbits < (1 << NUM_LOWBITS); lowbits++)
{
/* Combine highbits and lowbits into a floating-point number,
sign-extending the lowbits to 64-NUM_HIGHBITS bits. */
int
main ()
{
- unsigned int highbits;
- unsigned int lowbits;
int error = 0;
- for (highbits = 0; highbits < (1 << NUM_HIGHBITS); highbits++)
- for (lowbits = 0; lowbits < (1 << NUM_LOWBITS); lowbits++)
+ for (unsigned int highbits = 0; highbits < (1 << NUM_HIGHBITS); highbits++)
+ for (unsigned int lowbits = 0; lowbits < (1 << NUM_LOWBITS); lowbits++)
{
/* Combine highbits and lowbits into a floating-point number,
sign-extending the lowbits to 32-NUM_HIGHBITS bits. */
volatile DOUBLE z;
volatile DOUBLE result;
volatile DOUBLE expected;
- int xs;
- int xe;
- int ys;
- int ye;
- int ze;
DOUBLE sign;
- for (xs = 0; xs < 2; xs++)
- for (xe = -XE_RANGE; xe <= XE_RANGE; xe++)
+ for (int xs = 0; xs < 2; xs++)
+ for (int xe = -XE_RANGE; xe <= XE_RANGE; xe++)
{
x = pow_m1[xs] * POW2 (xe); /* (-1)^xs * 2^xe */
- for (ys = 0; ys < 2; ys++)
- for (ye = -YE_RANGE; ye <= YE_RANGE; ye++)
+ for (int ys = 0; ys < 2; ys++)
+ for (int ye = -YE_RANGE; ye <= YE_RANGE; ye++)
{
y = pow_m1[ys] * POW2 (ye); /* (-1)^ys * 2^ye */
sign = pow_m1[xs + ys];
/* Test addition (same signs). */
- for (ze = MIN_EXP - MANT_BIT; ze <= MAX_EXP - 1;)
+ for (int ze = MIN_EXP - MANT_BIT; ze <= MAX_EXP - 1;)
{
z = sign * POW2 (ze); /* (-1)^(xs+ys) * 2^ze */
result = my_fma (x, y, z);
}
/* Test subtraction (opposite signs). */
- for (ze = MIN_EXP - MANT_BIT; ze <= MAX_EXP - 1;)
+ for (int ze = MIN_EXP - MANT_BIT; ze <= MAX_EXP - 1;)
{
z = - sign * POW2 (ze); /* (-1)^(xs+ys+1) * 2^ze */
result = my_fma (x, y, z);
volatile DOUBLE z;
volatile DOUBLE result;
volatile DOUBLE expected;
- int i;
- int xs;
- int xe;
- int ys;
- int ye;
- int ze;
DOUBLE sign;
- for (i = 1; i <= MANT_BIT - 1; i++)
- for (xs = 0; xs < 2; xs++)
- for (xe = -XE_RANGE; xe <= XE_RANGE; xe++)
+ for (int i = 1; i <= MANT_BIT - 1; i++)
+ for (int xs = 0; xs < 2; xs++)
+ for (int xe = -XE_RANGE; xe <= XE_RANGE; xe++)
{
x = /* (-1)^xs * (2^xe + 2^(xe-i)) */
pow_m1[xs] * (POW2 (xe) + POW2 (xe - i));
- for (ys = 0; ys < 2; ys++)
- for (ye = -YE_RANGE; ye <= YE_RANGE; ye++)
+ for (int ys = 0; ys < 2; ys++)
+ for (int ye = -YE_RANGE; ye <= YE_RANGE; ye++)
{
y = /* (-1)^ys * (2^ye + 2^(ye-i)) */
pow_m1[ys] * (POW2 (ye) + POW2 (ye - i));
(-1)^(xs+ys) * (2^(xe+ye) + 2^(xe+ye-i+1) + 2^(xe+ye-2*i)) */
/* Test addition (same signs). */
- for (ze = MIN_EXP - MANT_BIT; ze <= MAX_EXP - 1;)
+ for (int ze = MIN_EXP - MANT_BIT; ze <= MAX_EXP - 1;)
{
z = sign * POW2 (ze); /* (-1)^(xs+ys) * 2^ze */
result = my_fma (x, y, z);
/* Test subtraction (opposite signs). */
if (i > 1)
- for (ze = MIN_EXP - MANT_BIT; ze <= MAX_EXP - 1;)
+ for (int ze = MIN_EXP - MANT_BIT; ze <= MAX_EXP - 1;)
{
z = - sign * POW2 (ze); /* (-1)^(xs+ys+1) * 2^ze */
result = my_fma (x, y, z);
volatile DOUBLE z;
volatile DOUBLE result;
volatile DOUBLE expected;
- int i;
- int xs;
- int xe;
- int ys;
- int ye;
- int ze;
DOUBLE sign;
- for (i = 1; i <= MANT_BIT - 1; i++)
- for (xs = 0; xs < 2; xs++)
- for (xe = -XE_RANGE; xe <= XE_RANGE; xe++)
+ for (int i = 1; i <= MANT_BIT - 1; i++)
+ for (int xs = 0; xs < 2; xs++)
+ for (int xe = -XE_RANGE; xe <= XE_RANGE; xe++)
{
x = /* (-1)^xs * (2^xe + 2^(xe-i)) */
pow_m1[xs] * (POW2 (xe) + POW2 (xe - i));
- for (ys = 0; ys < 2; ys++)
- for (ye = -YE_RANGE; ye <= YE_RANGE; ye++)
+ for (int ys = 0; ys < 2; ys++)
+ for (int ye = -YE_RANGE; ye <= YE_RANGE; ye++)
{
y = /* (-1)^ys * (2^ye - 2^(ye-i)) */
pow_m1[ys] * (POW2 (ye) - POW2 (ye - i));
(-1)^(xs+ys) * (2^(xe+ye) - 2^(xe+ye-2*i)) */
/* Test addition (same signs). */
- for (ze = MIN_EXP - MANT_BIT; ze <= MAX_EXP - 1;)
+ for (int ze = MIN_EXP - MANT_BIT; ze <= MAX_EXP - 1;)
{
z = sign * POW2 (ze); /* (-1)^(xs+ys) * 2^ze */
result = my_fma (x, y, z);
/* Test subtraction (opposite signs). */
if (i > 1)
- for (ze = MIN_EXP - MANT_BIT; ze <= MAX_EXP - 1;)
+ for (int ze = MIN_EXP - MANT_BIT; ze <= MAX_EXP - 1;)
{
z = - sign * POW2 (ze); /* (-1)^(xs+ys+1) * 2^ze */
result = my_fma (x, y, z);
static void
test_function (void)
{
- int i;
- int j;
const DOUBLE TWO_MANT_DIG =
/* Assume MANT_DIG <= 5 * 31.
Use the identity
* (DOUBLE) (1U << ((MANT_DIG - 1 + 4) / 5));
/* Randomized tests. */
- for (i = 0; i < SIZEOF (RANDOM) / 5; i++)
- for (j = 0; j < SIZEOF (RANDOM) / 5; j++)
+ for (int i = 0; i < SIZEOF (RANDOM) / 5; i++)
+ for (int j = 0; j < SIZEOF (RANDOM) / 5; j++)
{
DOUBLE x = L_(16.0) * RANDOM[i]; /* 0.0 <= x <= 16.0 */
DOUBLE y = RANDOM[j]; /* 0.0 <= y < 1.0 */
}
}
- for (i = 0; i < SIZEOF (RANDOM) / 5; i++)
- for (j = 0; j < SIZEOF (RANDOM) / 5; j++)
+ for (int i = 0; i < SIZEOF (RANDOM) / 5; i++)
+ for (int j = 0; j < SIZEOF (RANDOM) / 5; j++)
{
DOUBLE x = L_(1.0e9) * RANDOM[i]; /* 0.0 <= x <= 10^9 */
DOUBLE y = RANDOM[j]; /* 0.0 <= y < 1.0 */
{
int large_exp = (MAX_EXP - 1 < 1000 ? MAX_EXP - 1 : 1000);
DOUBLE large = my_ldexp (L_(1.0), large_exp); /* = 2^large_exp */
- for (i = 0; i < SIZEOF (RANDOM) / 10; i++)
- for (j = 0; j < SIZEOF (RANDOM) / 10; j++)
+ for (int i = 0; i < SIZEOF (RANDOM) / 10; i++)
+ for (int j = 0; j < SIZEOF (RANDOM) / 10; j++)
{
DOUBLE x = large * RANDOM[i]; /* 0.0 <= x <= 2^large_exp */
DOUBLE y = RANDOM[j]; /* 0.0 <= y < 1.0 */
{
int codepage = atoi (argv[argc - 1]);
int result;
- int i;
result = 77;
- for (i = 1; i < argc - 1; i++)
+ for (int i = 1; i < argc - 1; i++)
{
int ret = test_one_locale (argv[i], codepage);
{
/* Perform the test and test whether it triggers a permanent memory
allocation of more than MAX_ALLOC_TOTAL bytes. */
- int repeat;
- for (repeat = 0; repeat < NUM_ROUNDS; repeat++)
+ for (int repeat = 0; repeat < NUM_ROUNDS; repeat++)
{
/* This may produce a temporary memory allocation of 11000 bytes.
but should not result in a permanent memory allocation. */
int
main (void)
{
- int check_filepos;
-
- for (check_filepos = 0; check_filepos <= 1; check_filepos++)
+ for (int check_filepos = 0; check_filepos <= 1; check_filepos++)
{
FILE *fp;
{ /* Small memory allocations. */
#define N 10000
void *ptrs[N];
- size_t i;
- for (i = 0; i < N; i++)
+ for (size_t i = 0; i < N; i++)
ptrs[i] = malloc (15);
- for (i = 0; i < N; i++)
+ for (size_t i = 0; i < N; i++)
{
errno = 1789;
free (ptrs[i]);
{ /* Medium memory allocations. */
#define N 1000
void *ptrs[N];
- size_t i;
- for (i = 0; i < N; i++)
+ for (size_t i = 0; i < N; i++)
ptrs[i] = malloc (729);
- for (i = 0; i < N; i++)
+ for (size_t i = 0; i < N; i++)
{
errno = 1789;
free (ptrs[i]);
{ /* Large memory allocations. */
#define N 10
void *ptrs[N];
- size_t i;
- for (i = 0; i < N; i++)
+ for (size_t i = 0; i < N; i++)
ptrs[i] = malloc (5318153);
- for (i = 0; i < N; i++)
+ for (size_t i = 0; i < N; i++)
{
errno = 1789;
free (ptrs[i]);
/* Now add as many mappings as we can.
Stop at 65536, in order not to crash the machine (in case the
limit has been increased by the system administrator). */
- size_t i;
- for (i = 0; i < 65536; i++)
+ for (size_t i = 0; i < 65536; i++)
if (mmap (NULL, pagesize, PROT_READ, MAP_FILE | MAP_PRIVATE, fd, 0)
== (void *)(-1))
break;
static void
test_function (void)
{
- int i;
VOLATILE DOUBLE x;
{ /* NaN. */
ASSERT (signbit (mantissa));
}
- for (i = 1, x = L_(1.0); i <= MAX_EXP; i++, x *= L_(2.0))
- {
- int exp = -9999;
- DOUBLE mantissa = FREXP (x, &exp);
- ASSERT (exp == i);
- ASSERT (mantissa == L_(0.5));
- }
- for (i = 1, x = L_(1.0); i >= MIN_NORMAL_EXP; i--, x *= L_(0.5))
- {
- int exp = -9999;
- DOUBLE mantissa = FREXP (x, &exp);
- ASSERT (exp == i);
- ASSERT (mantissa == L_(0.5));
- }
- for (; i >= MIN_EXP - 100 && x > L_(0.0); i--, x *= L_(0.5))
- {
- int exp = -9999;
- DOUBLE mantissa = FREXP (x, &exp);
- ASSERT (exp == i);
- ASSERT (mantissa == L_(0.5));
- }
+ {
+ int i;
- for (i = 1, x = - L_(1.0); i <= MAX_EXP; i++, x *= L_(2.0))
- {
- int exp = -9999;
- DOUBLE mantissa = FREXP (x, &exp);
- ASSERT (exp == i);
- ASSERT (mantissa == - L_(0.5));
- }
- for (i = 1, x = - L_(1.0); i >= MIN_NORMAL_EXP; i--, x *= L_(0.5))
- {
- int exp = -9999;
- DOUBLE mantissa = FREXP (x, &exp);
- ASSERT (exp == i);
- ASSERT (mantissa == - L_(0.5));
- }
- for (; i >= MIN_EXP - 100 && x < L_(0.0); i--, x *= L_(0.5))
- {
- int exp = -9999;
- DOUBLE mantissa = FREXP (x, &exp);
- ASSERT (exp == i);
- ASSERT (mantissa == - L_(0.5));
- }
+ for (i = 1, x = L_(1.0); i <= MAX_EXP; i++, x *= L_(2.0))
+ {
+ int exp = -9999;
+ DOUBLE mantissa = FREXP (x, &exp);
+ ASSERT (exp == i);
+ ASSERT (mantissa == L_(0.5));
+ }
+ for (i = 1, x = L_(1.0); i >= MIN_NORMAL_EXP; i--, x *= L_(0.5))
+ {
+ int exp = -9999;
+ DOUBLE mantissa = FREXP (x, &exp);
+ ASSERT (exp == i);
+ ASSERT (mantissa == L_(0.5));
+ }
+ for (; i >= MIN_EXP - 100 && x > L_(0.0); i--, x *= L_(0.5))
+ {
+ int exp = -9999;
+ DOUBLE mantissa = FREXP (x, &exp);
+ ASSERT (exp == i);
+ ASSERT (mantissa == L_(0.5));
+ }
- for (i = 1, x = L_(1.01); i <= MAX_EXP; i++, x *= L_(2.0))
- {
- int exp = -9999;
- DOUBLE mantissa = FREXP (x, &exp);
- ASSERT (exp == i);
- ASSERT (mantissa == L_(0.505));
- }
- for (i = 1, x = L_(1.01); i >= MIN_NORMAL_EXP; i--, x *= L_(0.5))
- {
- int exp = -9999;
- DOUBLE mantissa = FREXP (x, &exp);
- ASSERT (exp == i);
- ASSERT (mantissa == L_(0.505));
- }
- for (; i >= MIN_EXP - 100 && x > L_(0.0); i--, x *= L_(0.5))
- {
- int exp = -9999;
- DOUBLE mantissa = FREXP (x, &exp);
- ASSERT (exp == i);
- ASSERT (mantissa >= L_(0.5));
- ASSERT (mantissa < L_(1.0));
- ASSERT (mantissa == my_ldexp (x, - exp));
- }
+ for (i = 1, x = - L_(1.0); i <= MAX_EXP; i++, x *= L_(2.0))
+ {
+ int exp = -9999;
+ DOUBLE mantissa = FREXP (x, &exp);
+ ASSERT (exp == i);
+ ASSERT (mantissa == - L_(0.5));
+ }
+ for (i = 1, x = - L_(1.0); i >= MIN_NORMAL_EXP; i--, x *= L_(0.5))
+ {
+ int exp = -9999;
+ DOUBLE mantissa = FREXP (x, &exp);
+ ASSERT (exp == i);
+ ASSERT (mantissa == - L_(0.5));
+ }
+ for (; i >= MIN_EXP - 100 && x < L_(0.0); i--, x *= L_(0.5))
+ {
+ int exp = -9999;
+ DOUBLE mantissa = FREXP (x, &exp);
+ ASSERT (exp == i);
+ ASSERT (mantissa == - L_(0.5));
+ }
- for (i = 1, x = L_(1.73205); i <= MAX_EXP; i++, x *= L_(2.0))
- {
- int exp = -9999;
- DOUBLE mantissa = FREXP (x, &exp);
- ASSERT (exp == i);
- ASSERT (mantissa == L_(0.866025));
- }
- for (i = 1, x = L_(1.73205); i >= MIN_NORMAL_EXP; i--, x *= L_(0.5))
- {
- int exp = -9999;
- DOUBLE mantissa = FREXP (x, &exp);
- ASSERT (exp == i);
- ASSERT (mantissa == L_(0.866025));
- }
- for (; i >= MIN_EXP - 100 && x > L_(0.0); i--, x *= L_(0.5))
- {
- int exp = -9999;
- DOUBLE mantissa = FREXP (x, &exp);
- ASSERT (exp == i || exp == i + 1);
- ASSERT (mantissa >= L_(0.5));
- ASSERT (mantissa < L_(1.0));
- ASSERT (mantissa == my_ldexp (x, - exp));
- }
+ for (i = 1, x = L_(1.01); i <= MAX_EXP; i++, x *= L_(2.0))
+ {
+ int exp = -9999;
+ DOUBLE mantissa = FREXP (x, &exp);
+ ASSERT (exp == i);
+ ASSERT (mantissa == L_(0.505));
+ }
+ for (i = 1, x = L_(1.01); i >= MIN_NORMAL_EXP; i--, x *= L_(0.5))
+ {
+ int exp = -9999;
+ DOUBLE mantissa = FREXP (x, &exp);
+ ASSERT (exp == i);
+ ASSERT (mantissa == L_(0.505));
+ }
+ for (; i >= MIN_EXP - 100 && x > L_(0.0); i--, x *= L_(0.5))
+ {
+ int exp = -9999;
+ DOUBLE mantissa = FREXP (x, &exp);
+ ASSERT (exp == i);
+ ASSERT (mantissa >= L_(0.5));
+ ASSERT (mantissa < L_(1.0));
+ ASSERT (mantissa == my_ldexp (x, - exp));
+ }
+
+ for (i = 1, x = L_(1.73205); i <= MAX_EXP; i++, x *= L_(2.0))
+ {
+ int exp = -9999;
+ DOUBLE mantissa = FREXP (x, &exp);
+ ASSERT (exp == i);
+ ASSERT (mantissa == L_(0.866025));
+ }
+ for (i = 1, x = L_(1.73205); i >= MIN_NORMAL_EXP; i--, x *= L_(0.5))
+ {
+ int exp = -9999;
+ DOUBLE mantissa = FREXP (x, &exp);
+ ASSERT (exp == i);
+ ASSERT (mantissa == L_(0.866025));
+ }
+ for (; i >= MIN_EXP - 100 && x > L_(0.0); i--, x *= L_(0.5))
+ {
+ int exp = -9999;
+ DOUBLE mantissa = FREXP (x, &exp);
+ ASSERT (exp == i || exp == i + 1);
+ ASSERT (mantissa >= L_(0.5));
+ ASSERT (mantissa < L_(1.0));
+ ASSERT (mantissa == my_ldexp (x, - exp));
+ }
+ }
/* Randomized tests. */
- for (i = 0; i < SIZEOF (RANDOM); i++)
+ for (int i = 0; i < SIZEOF (RANDOM); i++)
{
x = L_(20.0) * RANDOM[i] - L_(10.0); /* -10.0 <= x <= 10.0 */
{
int
main (void)
{
- int fd;
const char *file = "test-fsync.txt";
/* Assuming stdin and stdout are ttys, fsync is allowed to fail, but
may succeed as an extension. */
- for (fd = 0; fd < 2; fd++)
+ for (int fd = 0; fd < 2; fd++)
if (fsync (fd) != 0)
{
ASSERT (errno == EINVAL /* POSIX */
}
#endif
- fd = open (file, O_WRONLY|O_CREAT|O_TRUNC, 0644);
- ASSERT (0 <= fd);
- ASSERT (write (fd, "hello", 5) == 5);
- ASSERT (fsync (fd) == 0);
- ASSERT (close (fd) == 0);
+ {
+ int fd = open (file, O_WRONLY|O_CREAT|O_TRUNC, 0644);
+ ASSERT (0 <= fd);
+ ASSERT (write (fd, "hello", 5) == 5);
+ ASSERT (fsync (fd) == 0);
+ ASSERT (close (fd) == 0);
+ }
/* For a read-only regular file input file descriptor, fsync should
succeed (since at least atime changes can be synchronized).
On AIX and Cygwin, this test would fail. */
#if !(defined _AIX || defined __CYGWIN__)
- fd = open (file, O_RDONLY);
- ASSERT (0 <= fd);
{
- char buf[1];
- ASSERT (read (fd, buf, sizeof buf) == sizeof buf);
+ int fd = open (file, O_RDONLY);
+ ASSERT (0 <= fd);
+ {
+ char buf[1];
+ ASSERT (read (fd, buf, sizeof buf) == sizeof buf);
+ }
+ ASSERT (fsync (fd) == 0);
+ ASSERT (close (fd) == 0);
}
- ASSERT (fsync (fd) == 0);
- ASSERT (close (fd) == 0);
#endif
ASSERT (unlink (file) == 0);
FTS *ftsp;
FTSENT *e;
char buf[sizeof BASE + 100];
- int i;
enum { needles = 4 };
int needles_seen = 0;
struct stat st;
perror_exit (base, 4);
if (mkdir (base_d, 0777) != 0)
perror_exit (base_d, 5);
- for (i = 1; i <= 65536; i++)
+ for (int i = 1; i <= 65536; i++)
{
sprintf (buf, "%s/d/%i", base, i);
if (mkdir (buf, 0777) != 0)
}
/* Create empty files BASE/d/1/needle etc. */
- for (i = 1; i <= needles; i++)
+ for (int i = 1; i <= needles; i++)
{
int fd;
sprintf (buf, "%s/d/%d/needle", base, i);
if (memcmp (scratch, ciphertext_1, sizeof (ciphertext_1)))
{
- size_t i;
printf ("expected:\n");
- for (i = 0; i < 5; i++)
+ for (size_t i = 0; i < 5; i++)
printf ("%02x ", scratch[i] & 0xFF);
printf ("\ncomputed:\n");
- for (i = 0; i < 5; i++)
+ for (size_t i = 0; i < 5; i++)
printf ("%02x ", ciphertext_1[i] & 0xFF);
printf ("\n");
return 1;
if (memcmp (scratch, plaintext_1, sizeof (plaintext_1)))
{
- size_t i;
printf ("expected:\n");
- for (i = 0; i < 5; i++)
+ for (size_t i = 0; i < 5; i++)
printf ("%02x ", plaintext_1[i] & 0xFF);
printf ("\ncomputed:\n");
- for (i = 0; i < 5; i++)
+ for (size_t i = 0; i < 5; i++)
printf ("%02x ", scratch[i] & 0xFF);
printf ("\n");
return 1;
if (memcmp (scratch, ciphertext, sizeof (ciphertext)))
{
- size_t i;
printf ("expected:\n");
- for (i = 0; i < 5; i++)
+ for (size_t i = 0; i < 5; i++)
printf ("%02x ", scratch[i] & 0xFF);
printf ("\ncomputed:\n");
- for (i = 0; i < 5; i++)
+ for (size_t i = 0; i < 5; i++)
printf ("%02x ", ciphertext[i] & 0xFF);
printf ("\n");
return 1;
if (memcmp (scratch, plaintext, sizeof (plaintext)))
{
- size_t i;
printf ("expected:\n");
- for (i = 0; i < 5; i++)
+ for (size_t i = 0; i < 5; i++)
printf ("%02x ", plaintext[i] & 0xFF);
printf ("\ncomputed:\n");
- for (i = 0; i < 5; i++)
+ for (size_t i = 0; i < 5; i++)
printf ("%02x ", scratch[i] & 0xFF);
printf ("\n");
return 1;
* DES Maintenance Test
*/
{
- int i;
char key[8] = { 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55 };
char input[8] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
char result[8] = { 0x24, 0x6e, 0x9d, 0xb9, 0xc5, 0x50, 0x38, 0x1a };
char temp1[8], temp2[8], temp3[8];
gc_cipher_handle ctx_array[64];
- for (i = 0; i < 64; ++i)
+ for (int i = 0; i < 64; ++i)
{
gc_cipher_handle ctx;
if (memcmp (temp3, result, 8))
return 1;
- for (i = 0; i < 64; ++i)
+ for (int i = 0; i < 64; ++i)
gc_cipher_close (ctx_array[i]);
}
if (memcmp (digest, out, 16) != 0)
{
- size_t i;
printf ("hash 1 mismatch. expected:\n");
- for (i = 0; i < 16; i++)
+ for (size_t i = 0; i < 16; i++)
printf ("%02x ", digest[i] & 0xFF);
printf ("\ncomputed:\n");
- for (i = 0; i < 16; i++)
+ for (size_t i = 0; i < 16; i++)
printf ("%02x ", out[i] & 0xFF);
printf ("\n");
return 1;
if (memcmp (digest, out, GC_SHA1_DIGEST_SIZE) != 0)
{
- size_t i;
printf ("hash 1 mismatch. expected:\n");
- for (i = 0; i < 16; i++)
+ for (size_t i = 0; i < 16; i++)
printf ("%02x ", digest[i] & 0xFF);
printf ("\ncomputed:\n");
- for (i = 0; i < 16; i++)
+ for (size_t i = 0; i < 16; i++)
printf ("%02x ", out[i] & 0xFF);
printf ("\n");
return 1;
if (memcmp (digest, out, GC_SHA256_DIGEST_SIZE) != 0)
{
- size_t i;
printf ("hash 1 mismatch. expected:\n");
- for (i = 0; i < GC_SHA256_DIGEST_SIZE; i++)
+ for (size_t i = 0; i < GC_SHA256_DIGEST_SIZE; i++)
printf ("%02x ", digest[i] & 0xFF);
printf ("\ncomputed:\n");
- for (i = 0; i < GC_SHA256_DIGEST_SIZE; i++)
+ for (size_t i = 0; i < GC_SHA256_DIGEST_SIZE; i++)
printf ("%02x ", out[i] & 0xFF);
printf ("\n");
return 1;
if (memcmp (digest, out, GC_SHA512_DIGEST_SIZE) != 0)
{
- size_t i;
printf ("hash 1 mismatch. expected:\n");
- for (i = 0; i < GC_SHA512_DIGEST_SIZE; i++)
+ for (size_t i = 0; i < GC_SHA512_DIGEST_SIZE; i++)
printf ("%02x ", digest[i] & 0xFF);
printf ("\ncomputed:\n");
- for (i = 0; i < GC_SHA512_DIGEST_SIZE; i++)
+ for (size_t i = 0; i < GC_SHA512_DIGEST_SIZE; i++)
printf ("%02x ", out[i] & 0xFF);
printf ("\n");
return 1;
if (memcmp (out, expect, 16) != 0)
{
- size_t i;
printf ("md2 1 mismatch. expected:\n");
- for (i = 0; i < 16; i++)
+ for (size_t i = 0; i < 16; i++)
printf ("%02x ", expect[i] & 0xFF);
printf ("\ncomputed:\n");
- for (i = 0; i < 16; i++)
+ for (size_t i = 0; i < 16; i++)
printf ("%02x ", out[i] & 0xFF);
printf ("\n");
return 1;
if (memcmp (out, expect, 16) != 0)
{
- size_t i;
printf ("md2 2 mismatch. expected:\n");
- for (i = 0; i < 16; i++)
+ for (size_t i = 0; i < 16; i++)
printf ("%02x ", expect[i] & 0xFF);
printf ("\ncomputed:\n");
- for (i = 0; i < 16; i++)
+ for (size_t i = 0; i < 16; i++)
printf ("%02x ", out[i] & 0xFF);
printf ("\n");
return 1;
}
if (memcmp (p, expect, 16) != 0)
- {
- size_t i;
+ {
printf ("md2 3 mismatch. expected:\n");
- for (i = 0; i < 16; i++)
+ for (size_t i = 0; i < 16; i++)
printf ("%02x ", expect[i] & 0xFF);
printf ("\ncomputed:\n");
- for (i = 0; i < 16; i++)
+ for (size_t i = 0; i < 16; i++)
printf ("%02x ", p[i] & 0xFF);
printf ("\n");
return 1;
if (memcmp (out, expect, 16) != 0)
{
- size_t i;
printf ("md4 1 mismatch. expected:\n");
- for (i = 0; i < 16; i++)
+ for (size_t i = 0; i < 16; i++)
printf ("%02x ", expect[i] & 0xFF);
printf ("\ncomputed:\n");
- for (i = 0; i < 16; i++)
+ for (size_t i = 0; i < 16; i++)
printf ("%02x ", out[i] & 0xFF);
printf ("\n");
return 1;
if (memcmp (out, expect, 16) != 0)
{
- size_t i;
printf ("md4 1 mismatch. expected:\n");
- for (i = 0; i < 16; i++)
+ for (size_t i = 0; i < 16; i++)
printf ("%02x ", expect[i] & 0xFF);
printf ("\ncomputed:\n");
- for (i = 0; i < 16; i++)
+ for (size_t i = 0; i < 16; i++)
printf ("%02x ", out[i] & 0xFF);
printf ("\n");
return 1;
if (memcmp (p, expect, 16) != 0)
{
- size_t i;
printf ("md4 1 mismatch. expected:\n");
- for (i = 0; i < 16; i++)
+ for (size_t i = 0; i < 16; i++)
printf ("%02x ", expect[i] & 0xFF);
printf ("\ncomputed:\n");
- for (i = 0; i < 16; i++)
+ for (size_t i = 0; i < 16; i++)
printf ("%02x ", p[i] & 0xFF);
printf ("\n");
return 1;
if (memcmp (out, expect, 16) != 0)
{
- size_t i;
printf ("md5 1 mismatch. expected:\n");
- for (i = 0; i < 16; i++)
+ for (size_t i = 0; i < 16; i++)
printf ("%02x ", expect[i] & 0xFF);
printf ("\ncomputed:\n");
- for (i = 0; i < 16; i++)
+ for (size_t i = 0; i < 16; i++)
printf ("%02x ", out[i] & 0xFF);
printf ("\n");
return 1;
if (memcmp (out, expect, 16) != 0)
{
- size_t i;
printf ("md5 2 mismatch. expected:\n");
- for (i = 0; i < 16; i++)
+ for (size_t i = 0; i < 16; i++)
printf ("%02x ", expect[i] & 0xFF);
printf ("\ncomputed:\n");
- for (i = 0; i < 16; i++)
+ for (size_t i = 0; i < 16; i++)
printf ("%02x ", out[i] & 0xFF);
printf ("\n");
return 1;
}
if (memcmp (p, expect, 16) != 0)
- {
- size_t i;
+ {
printf ("md5 3 mismatch. expected:\n");
- for (i = 0; i < 16; i++)
+ for (size_t i = 0; i < 16; i++)
printf ("%02x ", expect[i] & 0xFF);
printf ("\ncomputed:\n");
- for (i = 0; i < 16; i++)
+ for (size_t i = 0; i < 16; i++)
printf ("%02x ", p[i] & 0xFF);
printf ("\n");
return 1;
int
main (int argc, char *argv[])
{
- size_t i;
int rc;
char out[BUFSIZ];
- for (i = 0; i < sizeof (pkcs5) / sizeof (pkcs5[0]); i++)
+ for (size_t i = 0; i < sizeof (pkcs5) / sizeof (pkcs5[0]); i++)
{
rc = gc_pbkdf2_sha1 (pkcs5[i].password, strlen (pkcs5[i].password),
pkcs5[i].salt, strlen (pkcs5[i].salt),
int
main (int argc, char *argv[])
{
- size_t i;
int rc;
char out[BUFSIZ];
return 1;
}
- for (i = 0; i < sizeof (pkcs5) / sizeof (pkcs5[0]); i++)
+ for (size_t i = 0; i < sizeof (pkcs5) / sizeof (pkcs5[0]); i++)
{
rc = gc_pbkdf2_hmac (pkcs5[i].hash,
pkcs5[i].password, strlen (pkcs5[i].password),
char ct[] = "\xC3\x4C\x05\x2C\xC0\xDA\x8D\x73"
"\x45\x1A\xFE\x5F\x03\xBE\x29\x7F";
gc_cipher_handle ctx;
- size_t round;
rc = gc_cipher_open (GC_AES128, GC_ECB, &ctx);
if (rc != GC_OK)
memcpy (buf, pt, 16);
- for (round = 0; round < 10000; round++)
+ for (size_t round = 0; round < 10000; round++)
{
rc = gc_cipher_encrypt_inline (ctx, 16, buf);
if (rc != GC_OK)
if (memcmp (buf, ct, 16) != 0)
{
- size_t i;
printf ("expected:\n");
- for (i = 0; i < 16; i++)
+ for (size_t i = 0; i < 16; i++)
printf ("%02x ", ct[i] & 0xFF);
printf ("\ncomputed:\n");
- for (i = 0; i < 16; i++)
+ for (size_t i = 0; i < 16; i++)
printf ("%02x ", buf[i] & 0xFF);
printf ("\n");
return 1;
}
- for (round = 0; round < 10000; round++)
+ for (size_t round = 0; round < 10000; round++)
{
rc = gc_cipher_decrypt_inline (ctx, 16, buf);
if (rc != GC_OK)
if (memcmp (buf, pt, 16) != 0)
{
- size_t i;
printf ("expected:\n");
- for (i = 0; i < 16; i++)
+ for (size_t i = 0; i < 16; i++)
printf ("%02x ", pt[i] & 0xFF);
printf ("\ncomputed:\n");
- for (i = 0; i < 16; i++)
+ for (size_t i = 0; i < 16; i++)
printf ("%02x ", buf[i] & 0xFF);
printf ("\n");
return 1;
char ct[] = "\x66\xe9\x4b\xd4\xef\x8a\x2c\x3b"
"\x88\x4c\xfa\x59\xca\x34\x2b\x2e";
gc_cipher_handle ctx;
- size_t round;
rc = gc_cipher_open (GC_AES128, GC_CBC, &ctx);
if (rc != GC_OK)
memcpy (buf, pt, 16);
- for (round = 0; round < 10000; round++)
+ for (size_t round = 0; round < 10000; round++)
{
rc = gc_cipher_encrypt_inline (ctx, 16, buf);
if (rc != GC_OK)
if (memcmp (buf, ct, 16) != 0)
{
- size_t i;
printf ("expected:\n");
- for (i = 0; i < 16; i++)
+ for (size_t i = 0; i < 16; i++)
printf ("%02x ", ct[i] & 0xFF);
printf ("\ncomputed:\n");
- for (i = 0; i < 16; i++)
+ for (size_t i = 0; i < 16; i++)
printf ("%02x ", buf[i] & 0xFF);
printf ("\n");
return 1;
if (memcmp (out, expect, 20) != 0)
{
- size_t i;
printf ("sha1 test1 mismatch. expected:\n");
- for (i = 0; i < 20; i++)
+ for (size_t i = 0; i < 20; i++)
printf ("%02x ", expect[i] & 0xFF);
printf ("\ncomputed:\n");
- for (i = 0; i < 20; i++)
+ for (size_t i = 0; i < 20; i++)
printf ("%02x ", out[i] & 0xFF);
printf ("\n");
return 1;
if (memcmp (out, expect, 20) != 0)
{
- size_t i;
printf ("sha1 test2 mismatch. expected:\n");
- for (i = 0; i < 20; i++)
+ for (size_t i = 0; i < 20; i++)
printf ("%02x ", expect[i] & 0xFF);
printf ("\ncomputed:\n");
- for (i = 0; i < 20; i++)
+ for (size_t i = 0; i < 20; i++)
printf ("%02x ", out[i] & 0xFF);
printf ("\n");
return 1;
if (memcmp (p, expect, 20) != 0)
{
- size_t i;
printf ("sha1 test3 mismatch. expected:\n");
- for (i = 0; i < 20; i++)
+ for (size_t i = 0; i < 20; i++)
printf ("%02x ", expect[i] & 0xFF);
printf ("\ncomputed:\n");
- for (i = 0; i < 20; i++)
+ for (size_t i = 0; i < 20; i++)
printf ("%02x ", p[i] & 0xFF);
printf ("\n");
return 1;
if (memcmp (out, expect, 32) != 0)
{
- size_t i;
printf ("sha256 test1 mismatch. expected:\n");
- for (i = 0; i < 32; i++)
+ for (size_t i = 0; i < 32; i++)
printf ("%02x ", expect[i] & 0xFF);
printf ("\ncomputed:\n");
- for (i = 0; i < 32; i++)
+ for (size_t i = 0; i < 32; i++)
printf ("%02x ", out[i] & 0xFF);
printf ("\n");
return 1;
if (memcmp (out, expect, 32) != 0)
{
- size_t i;
printf ("sha256 test2 mismatch. expected:\n");
- for (i = 0; i < 32; i++)
+ for (size_t i = 0; i < 32; i++)
printf ("%02x ", expect[i] & 0xFF);
printf ("\ncomputed:\n");
- for (i = 0; i < 32; i++)
+ for (size_t i = 0; i < 32; i++)
printf ("%02x ", out[i] & 0xFF);
printf ("\n");
return 1;
if (memcmp (p, expect, 32) != 0)
{
- size_t i;
printf ("sha256 test3 mismatch. expected:\n");
- for (i = 0; i < 32; i++)
+ for (size_t i = 0; i < 32; i++)
printf ("%02x ", expect[i] & 0xFF);
printf ("\ncomputed:\n");
- for (i = 0; i < 32; i++)
+ for (size_t i = 0; i < 32; i++)
printf ("%02x ", p[i] & 0xFF);
printf ("\n");
return 1;
if (memcmp (out, expect, 64) != 0)
{
- size_t i;
printf ("sha512 test1 mismatch. expected:\n");
- for (i = 0; i < 64; i++)
+ for (size_t i = 0; i < 64; i++)
printf ("%02x ", expect[i] & 0xFF);
printf ("\ncomputed:\n");
- for (i = 0; i < 64; i++)
+ for (size_t i = 0; i < 64; i++)
printf ("%02x ", out[i] & 0xFF);
printf ("\n");
return 1;
if (memcmp (out, expect, 64) != 0)
{
- size_t i;
printf ("sha512 test2 mismatch. expected:\n");
- for (i = 0; i < 64; i++)
+ for (size_t i = 0; i < 64; i++)
printf ("%02x ", expect[i] & 0xFF);
printf ("\ncomputed:\n");
- for (i = 0; i < 64; i++)
+ for (size_t i = 0; i < 64; i++)
printf ("%02x ", out[i] & 0xFF);
printf ("\n");
return 1;
if (memcmp (p, expect, 64) != 0)
{
- size_t i;
printf ("sha512 test3 mismatch. expected:\n");
- for (i = 0; i < 64; i++)
+ for (size_t i = 0; i < 64; i++)
printf ("%02x ", expect[i] & 0xFF);
printf ("\ncomputed:\n");
- for (i = 0; i < 64; i++)
+ for (size_t i = 0; i < 64; i++)
printf ("%02x ", p[i] & 0xFF);
printf ("\n");
return 1;
if (memcmp (out, expect, 32) != 0)
{
- size_t i;
printf ("sm3 mismatch. expected:\n");
- for (i = 0; i < 32; i++)
+ for (size_t i = 0; i < 32; i++)
printf ("%02x ", (unsigned int) expect[i] & 0xFF);
printf ("\ncomputed:\n");
- for (i = 0; i < 32; i++)
+ for (size_t i = 0; i < 32; i++)
printf ("%02x ", (unsigned int) out[i] & 0xFF);
printf ("\n");
return 1;
if (memcmp (out, expect, 32) != 0)
{
- size_t i;
printf ("sm3' mismatch. expected:\n");
- for (i = 0; i < 32; i++)
+ for (size_t i = 0; i < 32; i++)
printf ("%02x ", (unsigned int) expect[i] & 0xFF);
printf ("\ncomputed:\n");
- for (i = 0; i < 32; i++)
+ for (size_t i = 0; i < 32; i++)
printf ("%02x ", (unsigned int) out[i] & 0xFF);
printf ("\n");
return 1;
if (memcmp (p, expect, 32) != 0)
{
- size_t i;
printf ("sm3 mismatch. expected:\n");
- for (i = 0; i < 32; i++)
+ for (size_t i = 0; i < 32; i++)
printf ("%02x ", (unsigned int) expect[i] & 0xFF);
printf ("\ncomputed:\n");
- for (i = 0; i < 32; i++)
+ for (size_t i = 0; i < 32; i++)
printf ("%02x ", (unsigned int) p[i] & 0xFF);
printf ("\n");
return 1;
static int skip = 0;
struct addrinfo hints;
struct addrinfo *hints_p;
- struct addrinfo *ai0, *ai;
+ struct addrinfo *ai0;
int res;
int err;
return 1;
}
- for (ai = ai0; ai; ai = ai->ai_next)
+ for (struct addrinfo *ai = ai0; ai; ai = ai->ai_next)
{
void *ai_addr = ai->ai_addr;
struct sockaddr_in *sock_addr = ai_addr;
So clean up here, right away, even though the driving
shell script would also clean up. */
{
- size_t i;
-
/* Try rmdir first, in case the chdir failed. */
rmdir (DIR_NAME);
- for (i = 0; i <= n_chdirs; i++)
+ for (size_t i = 0; i <= n_chdirs; i++)
{
if (chdir ("..") < 0)
break;
list the returned groups. */
if (1 < argc)
{
- int i;
- for (i = 0; i < result; i++)
+ for (int i = 0; i < result; i++)
printf ("%d\n", (int) groups[i]);
}
free (groups);
{
char smallbuf[1024];
size_t n = strlen (buf);
- size_t i;
- for (i = 0; i <= n; i++)
+ for (size_t i = 0; i <= n; i++)
{
err = getlogin_r (smallbuf, i);
if (i == 0)
/* Larger file size. */
rewind (f);
- {
- int i;
- for (i = 0; i < 16; i++)
- fprintf (f, "%500x%c", i + 0u, i % 2 ? '\n' : '\r');
- }
+ for (int i = 0; i < 16; i++)
+ fprintf (f, "%500x%c", i + 0u, i % 2 ? '\n' : '\r');
rewind (f);
{
char buffer[502];
static void
test_getopt (void)
{
- int start;
bool posixly = !!getenv ("POSIXLY_CORRECT");
/* See comment in getopt.c:
glibc gets a LSB-compliant getopt.
#endif
/* Test processing of boolean options. */
- for (start = OPTIND_MIN; start <= 1; start++)
+ for (int start = OPTIND_MIN; start <= 1; start++)
{
int a_seen = 0;
int b_seen = 0;
ASSERT (optind == 2);
ASSERT (!output);
}
- for (start = OPTIND_MIN; start <= 1; start++)
+ for (int start = OPTIND_MIN; start <= 1; start++)
{
int a_seen = 0;
int b_seen = 0;
ASSERT (optind == 3);
ASSERT (!output);
}
- for (start = OPTIND_MIN; start <= 1; start++)
+ for (int start = OPTIND_MIN; start <= 1; start++)
{
int a_seen = 0;
int b_seen = 0;
ASSERT (optind == 2);
ASSERT (!output);
}
- for (start = OPTIND_MIN; start <= 1; start++)
+ for (int start = OPTIND_MIN; start <= 1; start++)
{
int a_seen = 0;
int b_seen = 0;
}
/* Test processing of options with arguments. */
- for (start = OPTIND_MIN; start <= 1; start++)
+ for (int start = OPTIND_MIN; start <= 1; start++)
{
int a_seen = 0;
int b_seen = 0;
ASSERT (optind == 2);
ASSERT (!output);
}
- for (start = OPTIND_MIN; start <= 1; start++)
+ for (int start = OPTIND_MIN; start <= 1; start++)
{
int a_seen = 0;
int b_seen = 0;
ASSERT (optind == 3);
ASSERT (!output);
}
- for (start = OPTIND_MIN; start <= 1; start++)
+ for (int start = OPTIND_MIN; start <= 1; start++)
{
int a_seen = 0;
int b_seen = 0;
#if GNULIB_TEST_GETOPT_GNU
/* Test processing of options with optional arguments. */
- for (start = OPTIND_MIN; start <= 1; start++)
+ for (int start = OPTIND_MIN; start <= 1; start++)
{
int a_seen = 0;
int b_seen = 0;
ASSERT (optind == 2);
ASSERT (!output);
}
- for (start = OPTIND_MIN; start <= 1; start++)
+ for (int start = OPTIND_MIN; start <= 1; start++)
{
int a_seen = 0;
int b_seen = 0;
ASSERT (optind == 2);
ASSERT (!output);
}
- for (start = OPTIND_MIN; start <= 1; start++)
+ for (int start = OPTIND_MIN; start <= 1; start++)
{
int a_seen = 0;
int b_seen = 0;
/* Check that invalid options are recognized; and that both opterr
and leading ':' can silence output. */
- for (start = OPTIND_MIN; start <= 1; start++)
+ for (int start = OPTIND_MIN; start <= 1; start++)
{
int a_seen = 0;
int b_seen = 0;
ASSERT (optind == 5);
ASSERT (output);
}
- for (start = OPTIND_MIN; start <= 1; start++)
+ for (int start = OPTIND_MIN; start <= 1; start++)
{
int a_seen = 0;
int b_seen = 0;
ASSERT (optind == 5);
ASSERT (!output);
}
- for (start = OPTIND_MIN; start <= 1; start++)
+ for (int start = OPTIND_MIN; start <= 1; start++)
{
int a_seen = 0;
int b_seen = 0;
ASSERT (optind == 5);
ASSERT (!output);
}
- for (start = OPTIND_MIN; start <= 1; start++)
+ for (int start = OPTIND_MIN; start <= 1; start++)
{
int a_seen = 0;
int b_seen = 0;
ASSERT (optind == 5);
ASSERT (output);
}
- for (start = OPTIND_MIN; start <= 1; start++)
+ for (int start = OPTIND_MIN; start <= 1; start++)
{
int a_seen = 0;
int b_seen = 0;
ASSERT (optind == 5);
ASSERT (!output);
}
- for (start = OPTIND_MIN; start <= 1; start++)
+ for (int start = OPTIND_MIN; start <= 1; start++)
{
int a_seen = 0;
int b_seen = 0;
}
/* Check for missing argument behavior. */
- for (start = OPTIND_MIN; start <= 1; start++)
+ for (int start = OPTIND_MIN; start <= 1; start++)
{
int a_seen = 0;
int b_seen = 0;
ASSERT (optind == 2);
ASSERT (output);
}
- for (start = OPTIND_MIN; start <= 1; start++)
+ for (int start = OPTIND_MIN; start <= 1; start++)
{
int a_seen = 0;
int b_seen = 0;
ASSERT (optind == 2);
ASSERT (!output);
}
- for (start = OPTIND_MIN; start <= 1; start++)
+ for (int start = OPTIND_MIN; start <= 1; start++)
{
int a_seen = 0;
int b_seen = 0;
}
/* Check that by default, non-options arguments are moved to the end. */
- for (start = OPTIND_MIN; start <= 1; start++)
+ for (int start = OPTIND_MIN; start <= 1; start++)
{
int a_seen = 0;
int b_seen = 0;
}
/* Check that '--' ends the argument processing. */
- for (start = OPTIND_MIN; start <= 1; start++)
+ for (int start = OPTIND_MIN; start <= 1; start++)
{
int a_seen = 0;
int b_seen = 0;
#if GNULIB_TEST_GETOPT_GNU
/* Check that the '-' flag causes non-options to be returned in order. */
- for (start = OPTIND_MIN; start <= 1; start++)
+ for (int start = OPTIND_MIN; start <= 1; start++)
{
int a_seen = 0;
int b_seen = 0;
}
/* Check that '--' ends the argument processing. */
- for (start = OPTIND_MIN; start <= 1; start++)
+ for (int start = OPTIND_MIN; start <= 1; start++)
{
int a_seen = 0;
int b_seen = 0;
}
/* Check that the '-' flag has to come first. */
- for (start = OPTIND_MIN; start <= 1; start++)
+ for (int start = OPTIND_MIN; start <= 1; start++)
{
int a_seen = 0;
int b_seen = 0;
/* Check that the '+' flag causes the first non-option to terminate the
loop. */
- for (start = OPTIND_MIN; start <= 1; start++)
+ for (int start = OPTIND_MIN; start <= 1; start++)
{
int a_seen = 0;
int b_seen = 0;
ASSERT (optind == 1);
ASSERT (!output);
}
- for (start = OPTIND_MIN; start <= 1; start++)
+ for (int start = OPTIND_MIN; start <= 1; start++)
{
int a_seen = 0;
int b_seen = 0;
}
/* Check that '--' ends the argument processing. */
- for (start = OPTIND_MIN; start <= 1; start++)
+ for (int start = OPTIND_MIN; start <= 1; start++)
{
int a_seen = 0;
int b_seen = 0;
#endif /* GNULIB_TEST_GETOPT_GNU */
/* Check that the '+' flag has to come first. */
- for (start = OPTIND_MIN; start <= 1; start++)
+ for (int start = OPTIND_MIN; start <= 1; start++)
{
int a_seen = 0;
int b_seen = 0;
/* If GNU extensions are supported, require compliance with POSIX
interpretation on leading '+' behavior.
https://austingroupbugs.net/view.php?id=191 */
- for (start = OPTIND_MIN; start <= 1; start++)
+ for (int start = OPTIND_MIN; start <= 1; start++)
{
int a_seen = 0;
int b_seen = 0;
ASSERT (optind == 1);
ASSERT (!output);
}
- for (start = OPTIND_MIN; start <= 1; start++)
+ for (int start = OPTIND_MIN; start <= 1; start++)
{
int a_seen = 0;
int b_seen = 0;
ASSERT (optind == 2);
ASSERT (!output);
}
- for (start = OPTIND_MIN; start <= 1; start++)
+ for (int start = OPTIND_MIN; start <= 1; start++)
{
int a_seen = 0;
int b_seen = 0;
Technically, POSIX says the presence of ';' in the opt-string
gives unspecified behavior, so we only test this when GNU compliance
is desired. */
- for (start = OPTIND_MIN; start <= 1; start++)
+ for (int start = OPTIND_MIN; start <= 1; start++)
{
int argc = 0;
const char *argv[10];
static void
test_getopt_long (void)
{
- int start;
-
/* Test disambiguation of options. */
{
int argc = 0;
}
/* Test processing of boolean short options. */
- for (start = 0; start <= 1; start++)
+ for (int start = 0; start <= 1; start++)
{
const char *p_value = NULL;
const char *q_value = NULL;
ASSERT (unrecognized == 0);
ASSERT (optind == 2);
}
- for (start = 0; start <= 1; start++)
+ for (int start = 0; start <= 1; start++)
{
const char *p_value = NULL;
const char *q_value = NULL;
ASSERT (unrecognized == 0);
ASSERT (optind == 3);
}
- for (start = 0; start <= 1; start++)
+ for (int start = 0; start <= 1; start++)
{
const char *p_value = NULL;
const char *q_value = NULL;
ASSERT (unrecognized == 0);
ASSERT (optind == 2);
}
- for (start = 0; start <= 1; start++)
+ for (int start = 0; start <= 1; start++)
{
const char *p_value = NULL;
const char *q_value = NULL;
}
/* Test processing of boolean long options. */
- for (start = 0; start <= 1; start++)
+ for (int start = 0; start <= 1; start++)
{
const char *p_value = NULL;
const char *q_value = NULL;
ASSERT (unrecognized == 0);
ASSERT (optind == 2);
}
- for (start = 0; start <= 1; start++)
+ for (int start = 0; start <= 1; start++)
{
const char *p_value = NULL;
const char *q_value = NULL;
ASSERT (unrecognized == 0);
ASSERT (optind == 3);
}
- for (start = 0; start <= 1; start++)
+ for (int start = 0; start <= 1; start++)
{
const char *p_value = NULL;
const char *q_value = NULL;
}
/* Test processing of boolean long options via -W. */
- for (start = 0; start <= 1; start++)
+ for (int start = 0; start <= 1; start++)
{
const char *p_value = NULL;
const char *q_value = NULL;
ASSERT (unrecognized == 0);
ASSERT (optind == 2);
}
- for (start = 0; start <= 1; start++)
+ for (int start = 0; start <= 1; start++)
{
const char *p_value = NULL;
const char *q_value = NULL;
ASSERT (unrecognized == 0);
ASSERT (optind == 5);
}
- for (start = 0; start <= 1; start++)
+ for (int start = 0; start <= 1; start++)
{
const char *p_value = NULL;
const char *q_value = NULL;
}
/* Test processing of short options with arguments. */
- for (start = 0; start <= 1; start++)
+ for (int start = 0; start <= 1; start++)
{
const char *p_value = NULL;
const char *q_value = NULL;
ASSERT (unrecognized == 0);
ASSERT (optind == 2);
}
- for (start = 0; start <= 1; start++)
+ for (int start = 0; start <= 1; start++)
{
const char *p_value = NULL;
const char *q_value = NULL;
ASSERT (unrecognized == 0);
ASSERT (optind == 3);
}
- for (start = 0; start <= 1; start++)
+ for (int start = 0; start <= 1; start++)
{
const char *p_value = NULL;
const char *q_value = NULL;
}
/* Test processing of long options with arguments. */
- for (start = 0; start <= 1; start++)
+ for (int start = 0; start <= 1; start++)
{
const char *p_value = NULL;
const char *q_value = NULL;
ASSERT (unrecognized == 0);
ASSERT (optind == 2);
}
- for (start = 0; start <= 1; start++)
+ for (int start = 0; start <= 1; start++)
{
const char *p_value = NULL;
const char *q_value = NULL;
ASSERT (unrecognized == 0);
ASSERT (optind == 3);
}
- for (start = 0; start <= 1; start++)
+ for (int start = 0; start <= 1; start++)
{
const char *p_value = NULL;
const char *q_value = NULL;
}
/* Test processing of long options with arguments via -W. */
- for (start = 0; start <= 1; start++)
+ for (int start = 0; start <= 1; start++)
{
const char *p_value = NULL;
const char *q_value = NULL;
ASSERT (unrecognized == 0);
ASSERT (optind == 2);
}
- for (start = 0; start <= 1; start++)
+ for (int start = 0; start <= 1; start++)
{
const char *p_value = NULL;
const char *q_value = NULL;
ASSERT (unrecognized == 0);
ASSERT (optind == 4);
}
- for (start = 0; start <= 1; start++)
+ for (int start = 0; start <= 1; start++)
{
const char *p_value = NULL;
const char *q_value = NULL;
}
/* Test processing of short options with optional arguments. */
- for (start = 0; start <= 1; start++)
+ for (int start = 0; start <= 1; start++)
{
const char *p_value = NULL;
const char *q_value = NULL;
ASSERT (unrecognized == 0);
ASSERT (optind == 2);
}
- for (start = 0; start <= 1; start++)
+ for (int start = 0; start <= 1; start++)
{
const char *p_value = NULL;
const char *q_value = NULL;
ASSERT (unrecognized == 0);
ASSERT (optind == 2);
}
- for (start = 0; start <= 1; start++)
+ for (int start = 0; start <= 1; start++)
{
const char *p_value = NULL;
const char *q_value = NULL;
}
/* Test processing of long options with optional arguments. */
- for (start = 0; start <= 1; start++)
+ for (int start = 0; start <= 1; start++)
{
const char *p_value = NULL;
const char *q_value = NULL;
ASSERT (unrecognized == 0);
ASSERT (optind == 2);
}
- for (start = 0; start <= 1; start++)
+ for (int start = 0; start <= 1; start++)
{
const char *p_value = NULL;
const char *q_value = NULL;
ASSERT (unrecognized == 0);
ASSERT (optind == 2);
}
- for (start = 0; start <= 1; start++)
+ for (int start = 0; start <= 1; start++)
{
const char *p_value = NULL;
const char *q_value = NULL;
ASSERT (unrecognized == 0);
ASSERT (optind == 2);
}
- for (start = 0; start <= 1; start++)
+ for (int start = 0; start <= 1; start++)
{
const char *p_value = NULL;
const char *q_value = NULL;
}
/* Test processing of long options with optional arguments via -W. */
- for (start = 0; start <= 1; start++)
+ for (int start = 0; start <= 1; start++)
{
const char *p_value = NULL;
const char *q_value = NULL;
ASSERT (unrecognized == 0);
ASSERT (optind == 2);
}
- for (start = 0; start <= 1; start++)
+ for (int start = 0; start <= 1; start++)
{
const char *p_value = NULL;
const char *q_value = NULL;
ASSERT (unrecognized == 0);
ASSERT (optind == 2);
}
- for (start = 0; start <= 1; start++)
+ for (int start = 0; start <= 1; start++)
{
const char *p_value = NULL;
const char *q_value = NULL;
ASSERT (unrecognized == 0);
ASSERT (optind == 2);
}
- for (start = 0; start <= 1; start++)
+ for (int start = 0; start <= 1; start++)
{
const char *p_value = NULL;
const char *q_value = NULL;
ASSERT (unrecognized == 0);
ASSERT (optind == 3);
}
- for (start = 0; start <= 1; start++)
+ for (int start = 0; start <= 1; start++)
{
const char *p_value = NULL;
const char *q_value = NULL;
}
/* Check that invalid options are recognized. */
- for (start = 0; start <= 1; start++)
+ for (int start = 0; start <= 1; start++)
{
const char *p_value = NULL;
const char *q_value = NULL;
ASSERT (unrecognized == 'x');
ASSERT (optind == 5);
}
- for (start = 0; start <= 1; start++)
+ for (int start = 0; start <= 1; start++)
{
const char *p_value = NULL;
const char *q_value = NULL;
}
/* Check that unexpected arguments are recognized. */
- for (start = 0; start <= 1; start++)
+ for (int start = 0; start <= 1; start++)
{
const char *p_value = NULL;
const char *q_value = NULL;
ASSERT (unrecognized == 'a');
ASSERT (optind == 4);
}
- for (start = 0; start <= 1; start++)
+ for (int start = 0; start <= 1; start++)
{
const char *p_value = NULL;
const char *q_value = NULL;
}
/* Check that by default, non-options arguments are moved to the end. */
- for (start = 0; start <= 1; start++)
+ for (int start = 0; start <= 1; start++)
{
const char *p_value = NULL;
const char *q_value = NULL;
}
/* Check that '--' ends the argument processing. */
- for (start = 0; start <= 1; start++)
+ for (int start = 0; start <= 1; start++)
{
const char *p_value = NULL;
const char *q_value = NULL;
}
/* Check that the '-' flag causes non-options to be returned in order. */
- for (start = 0; start <= 1; start++)
+ for (int start = 0; start <= 1; start++)
{
const char *p_value = NULL;
const char *q_value = NULL;
}
/* Check that '--' ends the argument processing. */
- for (start = 0; start <= 1; start++)
+ for (int start = 0; start <= 1; start++)
{
const char *p_value = NULL;
const char *q_value = NULL;
}
/* Check that the '-' flag has to come first. */
- for (start = 0; start <= 1; start++)
+ for (int start = 0; start <= 1; start++)
{
const char *p_value = NULL;
const char *q_value = NULL;
/* Check that the '+' flag causes the first non-option to terminate the
loop. */
- for (start = 0; start <= 1; start++)
+ for (int start = 0; start <= 1; start++)
{
const char *p_value = NULL;
const char *q_value = NULL;
ASSERT (unrecognized == 0);
ASSERT (optind == 1);
}
- for (start = 0; start <= 1; start++)
+ for (int start = 0; start <= 1; start++)
{
const char *p_value = NULL;
const char *q_value = NULL;
}
/* Check that '--' ends the argument processing. */
- for (start = 0; start <= 1; start++)
+ for (int start = 0; start <= 1; start++)
{
const char *p_value = NULL;
const char *q_value = NULL;
}
/* Check that the '+' flag has to come first. */
- for (start = 0; start <= 1; start++)
+ for (int start = 0; start <= 1; start++)
{
const char *p_value = NULL;
const char *q_value = NULL;
static void
test_getopt_long_posix (void)
{
- int start;
-
/* Check that POSIXLY_CORRECT stops parsing the same as leading '+'. */
- for (start = 0; start <= 1; start++)
+ for (int start = 0; start <= 1; start++)
{
const char *p_value = NULL;
const char *q_value = NULL;
}
/* Check that POSIXLY_CORRECT doesn't change optional arguments. */
- for (start = 0; start <= 1; start++)
+ for (int start = 0; start <= 1; start++)
{
const char *p_value = NULL;
const char *q_value = NULL;
}
/* Check that leading - still sees options after non-options. */
- for (start = 0; start <= 1; start++)
+ for (int start = 0; start <= 1; start++)
{
const char *p_value = NULL;
const char *q_value = NULL;
for (;;)
{
struct timeval t;
- int i;
- for (i = 0; i < 1000000; i++)
+ for (int i = 0; i < 1000000; i++)
counter++;
ASSERT (gettimeofday (&t, NULL) == 0);
static void
second_pass (void)
{
- size_t i;
char *ptr;
/* Return to the start of the file. */
setusershell ();
/* Make sure order is preserved. */
- for (i = 0; i < shell_count; ++i)
+ for (size_t i = 0; i < shell_count; ++i)
{
ptr = getusershell ();
ASSERT (ptr != NULL);
int
main (int argc, char **argv)
{
- unsigned int i;
- unsigned int k;
unsigned int table_size[] = {1, 2, 3, 4, 5, 23, 53};
Hash_table *ht;
Hash_tuning tuning;
srand (seed);
}
- for (i = 0; i < ARRAY_CARDINALITY (table_size); i++)
+ for (unsigned int i = 0; i < ARRAY_CARDINALITY (table_size); i++)
{
size_t sz = table_size[i];
ht = hash_initialize (sz, NULL, hash_pjw, hash_compare_strings, NULL);
tuning.growth_threshold = 0.89;
/* Run with default tuning, then with custom tuning settings. */
- for (k = 0; k < 2; k++)
+ for (unsigned int k = 0; k < 2; k++)
{
Hash_tuning const *tune = (k == 0 ? NULL : &tuning);
/* Now, each entry is malloc'd. */
ht = hash_initialize (4651, tune, hash_pjw,
hash_compare_strings, hash_freer);
ASSERT (ht);
- for (i = 0; i < 10000; i++)
+ for (unsigned int i = 0; i < 10000; i++)
{
unsigned int op = rand () % 10;
switch (op)
const void *value1;
const void *key2;
const void *value2;
- size_t i;
iter1 = gl_map_iterator (map1);
iter2 = gl_map_iterator (map2);
- for (i = 0; i < n; i++)
+ for (size_t i = 0; i < n; i++)
{
ASSERT (gl_map_iterator_next (&iter1, &key1, &value1));
ASSERT (gl_map_iterator_next (&iter2, &key2, &value2));
qsort (pairs_of_map1, n, sizeof (struct pair), cmp_pairs_in_array);
qsort (pairs_of_map2, n, sizeof (struct pair), cmp_pairs_in_array);
}
- for (i = 0; i < n; i++)
+ for (size_t i = 0; i < n; i++)
{
ASSERT (pairs_of_map1[i].key == pairs_of_map2[i].key);
ASSERT (pairs_of_map1[i].value == pairs_of_map2[i].value);
{
size_t initial_size = RANDOM (20);
- size_t i;
- unsigned int repeat;
/* Create map1. */
map1 = gl_map_nx_create_empty (GL_ARRAY_MAP,
check_all (map1, map2);
/* Initialize them. */
- for (i = 0; i < initial_size; i++)
+ for (size_t i = 0; i < initial_size; i++)
{
const char *key = RANDOM_OBJECT ();
const char *value = RANDOM_OBJECT ();
check_all (map1, map2);
}
- for (repeat = 0; repeat < 100000; repeat++)
+ for (unsigned int repeat = 0; repeat < 100000; repeat++)
{
unsigned int operation = RANDOM (3);
switch (operation)
gl_set_iterator_t iter2;
const void *elt1;
const void *elt2;
- size_t i;
iter1 = gl_set_iterator (set1);
iter2 = gl_set_iterator (set2);
- for (i = 0; i < n; i++)
+ for (size_t i = 0; i < n; i++)
{
ASSERT (gl_set_iterator_next (&iter1, &elt1));
ASSERT (gl_set_iterator_next (&iter2, &elt2));
qsort (elements_of_set1, n, sizeof (const void *), cmp_objects_in_array);
qsort (elements_of_set2, n, sizeof (const void *), cmp_objects_in_array);
}
- for (i = 0; i < n; i++)
+ for (size_t i = 0; i < n; i++)
ASSERT (elements_of_set1[i] == elements_of_set2[i]);
free (elements_of_set2);
free (elements_of_set1);
string_hashcode (const void *elt)
{
size_t hashcode = 0;
- const char *s;
- for (s = (const char *) elt; *s != '\0'; s++)
+ for (const char *s = (const char *) elt; *s != '\0'; s++)
hashcode += (unsigned char) *s;
return hashcode;
}
{
size_t initial_size = RANDOM (20);
- size_t i;
- unsigned int repeat;
/* Create set1. */
set1 = gl_set_nx_create_empty (GL_ARRAY_SET, string_equals, string_hashcode, NULL);
check_all (set1, set2);
/* Initialize them. */
- for (i = 0; i < initial_size; i++)
+ for (size_t i = 0; i < initial_size; i++)
{
const char *obj = RANDOM_OBJECT ();
ASSERT (gl_set_nx_add (set1, obj) == gl_set_nx_add (set2, obj));
check_all (set1, set2);
}
- for (repeat = 0; repeat < 100000; repeat++)
+ for (unsigned int repeat = 0; repeat < 100000; repeat++)
{
unsigned int operation = RANDOM (3);
switch (operation)
if (memcmp (digest, out, 16) != 0)
{
- size_t i;
printf ("hash 1 mismatch. expected:\n");
- for (i = 0; i < 16; i++)
+ for (size_t i = 0; i < 16; i++)
printf ("%02x ", digest[i] & 0xFF);
printf ("\ncomputed:\n");
- for (i = 0; i < 16; i++)
+ for (size_t i = 0; i < 16; i++)
printf ("%02x ", out[i] & 0xFF);
printf ("\n");
exit (1);
if (memcmp (digest, out, 20) != 0)
{
- size_t i;
printf ("hash 1 mismatch. expected:\n");
- for (i = 0; i < 20; i++)
+ for (size_t i = 0; i < 20; i++)
printf ("%02x ", digest[i] & 0xFF);
printf ("\ncomputed:\n");
- for (i = 0; i < 20; i++)
+ for (size_t i = 0; i < 20; i++)
printf ("%02x ", out[i] & 0xFF);
printf ("\n");
exit (1);
if (memcmp (digest, out, 32) != 0)
{
- size_t i;
printf ("hash 1 mismatch. expected:\n");
- for (i = 0; i < 32; i++)
+ for (size_t i = 0; i < 32; i++)
printf ("%02x ", digest[i] & 0xFF);
printf ("\ncomputed:\n");
- for (i = 0; i < 32; i++)
+ for (size_t i = 0; i < 32; i++)
printf ("%02x ", out[i] & 0xFF);
printf ("\n");
exit (1);
if (memcmp (digest, out, 64) != 0)
{
- size_t i;
printf ("hash 1 mismatch. expected:\n");
- for (i = 0; i < 64; i++)
+ for (size_t i = 0; i < 64; i++)
printf ("%02x ", digest[i] & 0xFF);
printf ("\ncomputed:\n");
- for (i = 0; i < 64; i++)
+ for (size_t i = 0; i < 64; i++)
printf ("%02x ", out[i] & 0xFF);
printf ("\n");
exit (1);
static void
test_function (void)
{
- int i;
- int j;
const DOUBLE TWO_MANT_DIG =
/* Assume MANT_DIG <= 5 * 31.
Use the identity
}
/* Randomized tests. */
- for (i = 0; i < SIZEOF (RANDOM) / 5; i++)
- for (j = 0; j < SIZEOF (RANDOM) / 5;j++)
+ for (int i = 0; i < SIZEOF (RANDOM) / 5; i++)
+ for (int j = 0; j < SIZEOF (RANDOM) / 5;j++)
{
DOUBLE x = L_(16.0) * RANDOM[i]; /* 0.0 <= x <= 16.0 */
DOUBLE y = L_(16.0) * RANDOM[j]; /* 0.0 <= y <= 16.0 */
main (int argc, char *argv[])
{
bool verbose = false;
- int i;
#if HAVE_GETUID
int uid = getuid ();
/* Parse arguments.
-v enables verbose output.
*/
- for (i = 1; i < argc; i++)
+ for (int i = 1; i < argc; i++)
{
const char *arg = argv[i];
if (strcmp (arg, "-v") == 0)
main (int argc, char *argv[])
{
bool verbose = false;
- int i;
#if HAVE_GETUID
int uid = getuid ();
/* Parse arguments.
-v enables verbose output.
*/
- for (i = 1; i < argc; i++)
+ for (int i = 1; i < argc; i++)
{
const char *arg = argv[i];
if (strcmp (arg, "-v") == 0)
verbose = true;
}
- for (i = 0; i < 3; i++)
+ for (int i = 0; i < 3; i++)
{
if (verbose)
show ("before droptemp:");
int
main (void)
{
- int i;
-
- for (i = 0; i < sizeof float_tests / sizeof *float_tests; i++)
+ for (int i = 0; i < sizeof float_tests / sizeof *float_tests; i++)
{
union ieee754_float u;
u.f = float_tests[i].x;
return 3;
}
- for (i = 0; i < sizeof double_tests / sizeof *double_tests; i++)
+ for (int i = 0; i < sizeof double_tests / sizeof *double_tests; i++)
{
union ieee754_double u;
u.d = double_tests[i].x;
static void
test_function (void)
{
- int i;
VOLATILE DOUBLE x;
int y;
ASSERT (ILOGB (NAN) == FP_ILOGBNAN);
/* From here on, this test assumes FLT_RADIX == 2. */
-
- for (i = 1, x = L_(1.0); i <= MAX_EXP; i++, x *= L_(2.0))
- {
- y = ILOGB (x);
- ASSERT (y == i - 1);
- }
- for (i = 1, x = L_(1.0); i >= MIN_NORMAL_EXP; i--, x *= L_(0.5))
- {
- y = ILOGB (x);
- ASSERT (y == i - 1);
- }
- for (; i >= MIN_EXP - 100 && x > L_(0.0); i--, x *= L_(0.5))
- {
- y = ILOGB (x);
- ASSERT (y == i - 1);
- }
-
- for (i = 1, x = - L_(1.0); i <= MAX_EXP; i++, x *= L_(2.0))
- {
- y = ILOGB (x);
- ASSERT (y == i - 1);
- }
- for (i = 1, x = - L_(1.0); i >= MIN_NORMAL_EXP; i--, x *= L_(0.5))
- {
- y = ILOGB (x);
- ASSERT (y == i - 1);
- }
- for (; i >= MIN_EXP - 100 && x < L_(0.0); i--, x *= L_(0.5))
- {
- y = ILOGB (x);
- ASSERT (y == i - 1);
- }
-
- for (i = 1, x = L_(1.01); i <= MAX_EXP; i++, x *= L_(2.0))
- {
- y = ILOGB (x);
- ASSERT (y == i - 1);
- }
- for (i = 1, x = L_(1.01); i >= MIN_NORMAL_EXP; i--, x *= L_(0.5))
- {
- y = ILOGB (x);
- ASSERT (y == i - 1);
- }
- for (; i >= MIN_EXP - 100 && x > L_(0.0); i--, x *= L_(0.5))
- {
- y = ILOGB (x);
- ASSERT (y == i - 1);
- }
-
- for (i = 1, x = L_(1.73205); i <= MAX_EXP; i++, x *= L_(2.0))
- {
- y = ILOGB (x);
- ASSERT (y == i - 1);
- }
- for (i = 1, x = L_(1.73205); i >= MIN_NORMAL_EXP; i--, x *= L_(0.5))
- {
- y = ILOGB (x);
- ASSERT (y == i - 1);
- }
- for (; i >= MIN_EXP - 100 && x > L_(0.0); i--, x *= L_(0.5))
- {
- y = ILOGB (x);
- ASSERT (y == i - 1 || y == i);
- }
+ {
+ int i;
+
+ for (i = 1, x = L_(1.0); i <= MAX_EXP; i++, x *= L_(2.0))
+ {
+ y = ILOGB (x);
+ ASSERT (y == i - 1);
+ }
+ for (i = 1, x = L_(1.0); i >= MIN_NORMAL_EXP; i--, x *= L_(0.5))
+ {
+ y = ILOGB (x);
+ ASSERT (y == i - 1);
+ }
+ for (; i >= MIN_EXP - 100 && x > L_(0.0); i--, x *= L_(0.5))
+ {
+ y = ILOGB (x);
+ ASSERT (y == i - 1);
+ }
+
+ for (i = 1, x = - L_(1.0); i <= MAX_EXP; i++, x *= L_(2.0))
+ {
+ y = ILOGB (x);
+ ASSERT (y == i - 1);
+ }
+ for (i = 1, x = - L_(1.0); i >= MIN_NORMAL_EXP; i--, x *= L_(0.5))
+ {
+ y = ILOGB (x);
+ ASSERT (y == i - 1);
+ }
+ for (; i >= MIN_EXP - 100 && x < L_(0.0); i--, x *= L_(0.5))
+ {
+ y = ILOGB (x);
+ ASSERT (y == i - 1);
+ }
+
+ for (i = 1, x = L_(1.01); i <= MAX_EXP; i++, x *= L_(2.0))
+ {
+ y = ILOGB (x);
+ ASSERT (y == i - 1);
+ }
+ for (i = 1, x = L_(1.01); i >= MIN_NORMAL_EXP; i--, x *= L_(0.5))
+ {
+ y = ILOGB (x);
+ ASSERT (y == i - 1);
+ }
+ for (; i >= MIN_EXP - 100 && x > L_(0.0); i--, x *= L_(0.5))
+ {
+ y = ILOGB (x);
+ ASSERT (y == i - 1);
+ }
+
+ for (i = 1, x = L_(1.73205); i <= MAX_EXP; i++, x *= L_(2.0))
+ {
+ y = ILOGB (x);
+ ASSERT (y == i - 1);
+ }
+ for (i = 1, x = L_(1.73205); i >= MIN_NORMAL_EXP; i--, x *= L_(0.5))
+ {
+ y = ILOGB (x);
+ ASSERT (y == i - 1);
+ }
+ for (; i >= MIN_EXP - 100 && x > L_(0.0); i--, x *= L_(0.5))
+ {
+ y = ILOGB (x);
+ ASSERT (y == i - 1 || y == i);
+ }
+ }
/* Randomized tests. */
- for (i = 0; i < SIZEOF (RANDOM); i++)
+ for (int i = 0; i < SIZEOF (RANDOM); i++)
{
x = L_(20.0) * RANDOM[i] - L_(10.0); /* -10.0 <= x <= 10.0 */
if (x != L_(0.0))
ASSERT (ino_map_insert (ino_map, 0) == INO_MAP_INIT + 2);
ASSERT (ino_map_insert (ino_map, 0) == INO_MAP_INIT + 2);
- {
- int i;
- for (i = 0; i < 100; i++)
- {
- ASSERT (ino_map_insert (ino_map, 10000 + i) == INO_MAP_INIT + 3 + i);
- }
- }
+ for (int i = 0; i < 100; i++)
+ {
+ ASSERT (ino_map_insert (ino_map, 10000 + i) == INO_MAP_INIT + 3 + i);
+ }
ino_map_free (ino_map);
static int
naive (unsigned int x)
{
- int j;
- for (j = NBITS - 1; j >= 0; j--)
+ for (int j = NBITS - 1; j >= 0; j--)
if (x & (1U << j))
return j + 1;
return 0;
int
main (int argc, char *argv[])
{
- unsigned int x;
- int i;
-
- for (x = 0; x <= 256; x++)
+ for (unsigned int x = 0; x <= 256; x++)
ASSERT (integer_length (x) == naive (x));
- for (i = 0; i < NBITS; i++)
+ for (int i = 0; i < NBITS; i++)
{
ASSERT (integer_length (1U << i) == naive (1U << i));
ASSERT (integer_length (1U << i) == i + 1);
ASSERT (integer_length (-1U << i) == NBITS);
}
- for (i = 0; i < NBITS - 1; i++)
+ for (int i = 0; i < NBITS - 1; i++)
ASSERT (integer_length (3U << i) == i + 2);
- for (i = 0; i < NBITS - 2; i++)
+ for (int i = 0; i < NBITS - 2; i++)
ASSERT (integer_length (-3U << i) == NBITS);
- for (i = 0; i < NBITS - 2; i++)
+ for (int i = 0; i < NBITS - 2; i++)
{
ASSERT (integer_length (5U << i) == i + 3);
ASSERT (integer_length (7U << i) == i + 3);
}
- for (i = 0; i < NBITS - 3; i++)
+ for (int i = 0; i < NBITS - 3; i++)
{
ASSERT (integer_length (-5U << i) == NBITS);
ASSERT (integer_length (-7U << i) == NBITS);
static int
naive (unsigned long x)
{
- int j;
- for (j = NBITS - 1; j >= 0; j--)
+ for (int j = NBITS - 1; j >= 0; j--)
if (x & (1UL << j))
return j + 1;
return 0;
int
main (int argc, char *argv[])
{
- unsigned long x;
- int i;
-
- for (x = 0; x <= 256; x++)
+ for (unsigned long x = 0; x <= 256; x++)
ASSERT (integer_length_l (x) == naive (x));
- for (i = 0; i < NBITS; i++)
+ for (int i = 0; i < NBITS; i++)
{
ASSERT (integer_length_l (1UL << i) == naive (1UL << i));
ASSERT (integer_length_l (1UL << i) == i + 1);
ASSERT (integer_length_l (-1UL << i) == NBITS);
}
- for (i = 0; i < NBITS - 1; i++)
+ for (int i = 0; i < NBITS - 1; i++)
ASSERT (integer_length_l (3UL << i) == i + 2);
- for (i = 0; i < NBITS - 2; i++)
+ for (int i = 0; i < NBITS - 2; i++)
ASSERT (integer_length_l (-3UL << i) == NBITS);
- for (i = 0; i < NBITS - 2; i++)
+ for (int i = 0; i < NBITS - 2; i++)
{
ASSERT (integer_length_l (5UL << i) == i + 3);
ASSERT (integer_length_l (7UL << i) == i + 3);
}
- for (i = 0; i < NBITS - 3; i++)
+ for (int i = 0; i < NBITS - 3; i++)
{
ASSERT (integer_length_l (-5UL << i) == NBITS);
ASSERT (integer_length_l (-7UL << i) == NBITS);
static int
naive (unsigned long long x)
{
- int j;
- for (j = NBITS - 1; j >= 0; j--)
+ for (int j = NBITS - 1; j >= 0; j--)
if (x & (1ULL << j))
return j + 1;
return 0;
int
main (int argc, char *argv[])
{
- unsigned long x;
- int i;
-
- for (x = 0; x <= 256; x++)
+ for (unsigned long x = 0; x <= 256; x++)
ASSERT (integer_length_ll (x) == naive (x));
- for (i = 0; i < NBITS; i++)
+ for (int i = 0; i < NBITS; i++)
{
ASSERT (integer_length_ll (1ULL << i) == naive (1ULL << i));
ASSERT (integer_length_ll (1ULL << i) == i + 1);
ASSERT (integer_length_ll (-1ULL << i) == NBITS);
}
- for (i = 0; i < NBITS - 1; i++)
+ for (int i = 0; i < NBITS - 1; i++)
ASSERT (integer_length_ll (3ULL << i) == i + 2);
- for (i = 0; i < NBITS - 2; i++)
+ for (int i = 0; i < NBITS - 2; i++)
ASSERT (integer_length_ll (-3ULL << i) == NBITS);
- for (i = 0; i < NBITS - 2; i++)
+ for (int i = 0; i < NBITS - 2; i++)
{
ASSERT (integer_length_ll (5ULL << i) == i + 3);
ASSERT (integer_length_ll (7ULL << i) == i + 3);
}
- for (i = 0; i < NBITS - 3; i++)
+ for (int i = 0; i < NBITS - 3; i++)
{
ASSERT (integer_length_ll (-5ULL << i) == NBITS);
ASSERT (integer_length_ll (-7ULL << i) == NBITS);
- in the "POSIX" locale (which is usually the same as the "C" locale),
the alphanumeric characters include only the ASCII A ... Z and a ... z
and 0 ... 9 characters. */
- {
- int c;
-
- for (c = 0; c < 0x100; c++)
- switch (c)
- {
- case '\t': case '\v': case '\f':
- case ' ': case '!': case '"': case '#': case '%':
- case '&': case '\'': case '(': case ')': case '*':
- case '+': case ',': case '-': case '.': case '/':
- case '0': case '1': case '2': case '3': case '4':
- case '5': case '6': case '7': case '8': case '9':
- case ':': case ';': case '<': case '=': case '>':
- case '?':
- case 'A': case 'B': case 'C': case 'D': case 'E':
- case 'F': case 'G': case 'H': case 'I': case 'J':
- case 'K': case 'L': case 'M': case 'N': case 'O':
- case 'P': case 'Q': case 'R': case 'S': case 'T':
- case 'U': case 'V': case 'W': case 'X': case 'Y':
- case 'Z':
- case '[': case '\\': case ']': case '^': case '_':
- case 'a': case 'b': case 'c': case 'd': case 'e':
- case 'f': case 'g': case 'h': case 'i': case 'j':
- case 'k': case 'l': case 'm': case 'n': case 'o':
- case 'p': case 'q': case 'r': case 's': case 't':
- case 'u': case 'v': case 'w': case 'x': case 'y':
- case 'z': case '{': case '|': case '}': case '~':
- /* c is in the ISO C "basic character set". */
- is = isalnum_l ((unsigned char) c, locale);
- switch (c)
- {
- case '0': case '1': case '2': case '3': case '4':
- case '5': case '6': case '7': case '8': case '9':
- case 'A': case 'B': case 'C': case 'D': case 'E':
- case 'F': case 'G': case 'H': case 'I': case 'J':
- case 'K': case 'L': case 'M': case 'N': case 'O':
- case 'P': case 'Q': case 'R': case 'S': case 'T':
- case 'U': case 'V': case 'W': case 'X': case 'Y':
- case 'Z':
- case 'a': case 'b': case 'c': case 'd': case 'e':
- case 'f': case 'g': case 'h': case 'i': case 'j':
- case 'k': case 'l': case 'm': case 'n': case 'o':
- case 'p': case 'q': case 'r': case 's': case 't':
- case 'u': case 'v': case 'w': case 'x': case 'y':
- case 'z':
- ASSERT (is != 0);
- break;
- default:
- ASSERT (is == 0);
- break;
- }
- break;
- }
- }
+ for (int c = 0; c < 0x100; c++)
+ switch (c)
+ {
+ case '\t': case '\v': case '\f':
+ case ' ': case '!': case '"': case '#': case '%':
+ case '&': case '\'': case '(': case ')': case '*':
+ case '+': case ',': case '-': case '.': case '/':
+ case '0': case '1': case '2': case '3': case '4':
+ case '5': case '6': case '7': case '8': case '9':
+ case ':': case ';': case '<': case '=': case '>':
+ case '?':
+ case 'A': case 'B': case 'C': case 'D': case 'E':
+ case 'F': case 'G': case 'H': case 'I': case 'J':
+ case 'K': case 'L': case 'M': case 'N': case 'O':
+ case 'P': case 'Q': case 'R': case 'S': case 'T':
+ case 'U': case 'V': case 'W': case 'X': case 'Y':
+ case 'Z':
+ case '[': case '\\': case ']': case '^': case '_':
+ case 'a': case 'b': case 'c': case 'd': case 'e':
+ case 'f': case 'g': case 'h': case 'i': case 'j':
+ case 'k': case 'l': case 'm': case 'n': case 'o':
+ case 'p': case 'q': case 'r': case 's': case 't':
+ case 'u': case 'v': case 'w': case 'x': case 'y':
+ case 'z': case '{': case '|': case '}': case '~':
+ /* c is in the ISO C "basic character set". */
+ is = isalnum_l ((unsigned char) c, locale);
+ switch (c)
+ {
+ case '0': case '1': case '2': case '3': case '4':
+ case '5': case '6': case '7': case '8': case '9':
+ case 'A': case 'B': case 'C': case 'D': case 'E':
+ case 'F': case 'G': case 'H': case 'I': case 'J':
+ case 'K': case 'L': case 'M': case 'N': case 'O':
+ case 'P': case 'Q': case 'R': case 'S': case 'T':
+ case 'U': case 'V': case 'W': case 'X': case 'Y':
+ case 'Z':
+ case 'a': case 'b': case 'c': case 'd': case 'e':
+ case 'f': case 'g': case 'h': case 'i': case 'j':
+ case 'k': case 'l': case 'm': case 'n': case 'o':
+ case 'p': case 'q': case 'r': case 's': case 't':
+ case 'u': case 'v': case 'w': case 'x': case 'y':
+ case 'z':
+ ASSERT (is != 0);
+ break;
+ default:
+ ASSERT (is == 0);
+ break;
+ }
+ break;
+ }
}
int
- in the "POSIX" locale (which is usually the same as the "C" locale),
the alphabetic characters include only the ASCII A ... Z and a ... z
characters. */
- {
- int c;
-
- for (c = 0; c < 0x100; c++)
- switch (c)
- {
- case '\t': case '\v': case '\f':
- case ' ': case '!': case '"': case '#': case '%':
- case '&': case '\'': case '(': case ')': case '*':
- case '+': case ',': case '-': case '.': case '/':
- case '0': case '1': case '2': case '3': case '4':
- case '5': case '6': case '7': case '8': case '9':
- case ':': case ';': case '<': case '=': case '>':
- case '?':
- case 'A': case 'B': case 'C': case 'D': case 'E':
- case 'F': case 'G': case 'H': case 'I': case 'J':
- case 'K': case 'L': case 'M': case 'N': case 'O':
- case 'P': case 'Q': case 'R': case 'S': case 'T':
- case 'U': case 'V': case 'W': case 'X': case 'Y':
- case 'Z':
- case '[': case '\\': case ']': case '^': case '_':
- case 'a': case 'b': case 'c': case 'd': case 'e':
- case 'f': case 'g': case 'h': case 'i': case 'j':
- case 'k': case 'l': case 'm': case 'n': case 'o':
- case 'p': case 'q': case 'r': case 's': case 't':
- case 'u': case 'v': case 'w': case 'x': case 'y':
- case 'z': case '{': case '|': case '}': case '~':
- /* c is in the ISO C "basic character set". */
- is = isalpha_l ((unsigned char) c, locale);
- switch (c)
- {
- case 'A': case 'B': case 'C': case 'D': case 'E':
- case 'F': case 'G': case 'H': case 'I': case 'J':
- case 'K': case 'L': case 'M': case 'N': case 'O':
- case 'P': case 'Q': case 'R': case 'S': case 'T':
- case 'U': case 'V': case 'W': case 'X': case 'Y':
- case 'Z':
- case 'a': case 'b': case 'c': case 'd': case 'e':
- case 'f': case 'g': case 'h': case 'i': case 'j':
- case 'k': case 'l': case 'm': case 'n': case 'o':
- case 'p': case 'q': case 'r': case 's': case 't':
- case 'u': case 'v': case 'w': case 'x': case 'y':
- case 'z':
- ASSERT (is != 0);
- break;
- default:
- ASSERT (is == 0);
- break;
- }
- break;
- }
- }
+ for (int c = 0; c < 0x100; c++)
+ switch (c)
+ {
+ case '\t': case '\v': case '\f':
+ case ' ': case '!': case '"': case '#': case '%':
+ case '&': case '\'': case '(': case ')': case '*':
+ case '+': case ',': case '-': case '.': case '/':
+ case '0': case '1': case '2': case '3': case '4':
+ case '5': case '6': case '7': case '8': case '9':
+ case ':': case ';': case '<': case '=': case '>':
+ case '?':
+ case 'A': case 'B': case 'C': case 'D': case 'E':
+ case 'F': case 'G': case 'H': case 'I': case 'J':
+ case 'K': case 'L': case 'M': case 'N': case 'O':
+ case 'P': case 'Q': case 'R': case 'S': case 'T':
+ case 'U': case 'V': case 'W': case 'X': case 'Y':
+ case 'Z':
+ case '[': case '\\': case ']': case '^': case '_':
+ case 'a': case 'b': case 'c': case 'd': case 'e':
+ case 'f': case 'g': case 'h': case 'i': case 'j':
+ case 'k': case 'l': case 'm': case 'n': case 'o':
+ case 'p': case 'q': case 'r': case 's': case 't':
+ case 'u': case 'v': case 'w': case 'x': case 'y':
+ case 'z': case '{': case '|': case '}': case '~':
+ /* c is in the ISO C "basic character set". */
+ is = isalpha_l ((unsigned char) c, locale);
+ switch (c)
+ {
+ case 'A': case 'B': case 'C': case 'D': case 'E':
+ case 'F': case 'G': case 'H': case 'I': case 'J':
+ case 'K': case 'L': case 'M': case 'N': case 'O':
+ case 'P': case 'Q': case 'R': case 'S': case 'T':
+ case 'U': case 'V': case 'W': case 'X': case 'Y':
+ case 'Z':
+ case 'a': case 'b': case 'c': case 'd': case 'e':
+ case 'f': case 'g': case 'h': case 'i': case 'j':
+ case 'k': case 'l': case 'm': case 'n': case 'o':
+ case 'p': case 'q': case 'r': case 's': case 't':
+ case 'u': case 'v': case 'w': case 'x': case 'y':
+ case 'z':
+ ASSERT (is != 0);
+ break;
+ default:
+ ASSERT (is == 0);
+ break;
+ }
+ break;
+ }
}
int
int
main ()
{
- unsigned int c;
-
/* Verify the property in the "C" locale.
POSIX specifies in
<https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap07.html>
- in the "POSIX" locale (which is usually the same as the "C" locale),
the blank characters include only the ASCII <space> and <tab>
characters. */
- for (c = 0; c <= UCHAR_MAX; c++)
+ for (unsigned int c = 0; c <= UCHAR_MAX; c++)
ASSERT (!isblank (c) == !(c == ' ' || c == '\t'));
ASSERT (!isblank (EOF));
- in the "POSIX" locale (which is usually the same as the "C" locale),
the blank characters include only the ASCII <space> and <tab>
characters. */
- {
- int c;
-
- for (c = 0; c < 0x100; c++)
- switch (c)
- {
- case '\t':
- #if !(defined __FreeBSD__ || defined __NetBSD__)
- case '\v':
- #endif
- #if !defined __NetBSD__
- case '\f':
- #endif
- case ' ': case '!': case '"': case '#': case '%':
- case '&': case '\'': case '(': case ')': case '*':
- case '+': case ',': case '-': case '.': case '/':
- case '0': case '1': case '2': case '3': case '4':
- case '5': case '6': case '7': case '8': case '9':
- case ':': case ';': case '<': case '=': case '>':
- case '?':
- case 'A': case 'B': case 'C': case 'D': case 'E':
- case 'F': case 'G': case 'H': case 'I': case 'J':
- case 'K': case 'L': case 'M': case 'N': case 'O':
- case 'P': case 'Q': case 'R': case 'S': case 'T':
- case 'U': case 'V': case 'W': case 'X': case 'Y':
- case 'Z':
- case '[': case '\\': case ']': case '^': case '_':
- case 'a': case 'b': case 'c': case 'd': case 'e':
- case 'f': case 'g': case 'h': case 'i': case 'j':
- case 'k': case 'l': case 'm': case 'n': case 'o':
- case 'p': case 'q': case 'r': case 's': case 't':
- case 'u': case 'v': case 'w': case 'x': case 'y':
- case 'z': case '{': case '|': case '}': case '~':
- /* c is in the ISO C "basic character set". */
- is = isblank_l ((unsigned char) c, locale);
- if (c == '\t' || c == ' ')
- ASSERT (is != 0);
- else
- ASSERT (is == 0);
- break;
- }
- }
+ for (int c = 0; c < 0x100; c++)
+ switch (c)
+ {
+ case '\t':
+ #if !(defined __FreeBSD__ || defined __NetBSD__)
+ case '\v':
+ #endif
+ #if !defined __NetBSD__
+ case '\f':
+ #endif
+ case ' ': case '!': case '"': case '#': case '%':
+ case '&': case '\'': case '(': case ')': case '*':
+ case '+': case ',': case '-': case '.': case '/':
+ case '0': case '1': case '2': case '3': case '4':
+ case '5': case '6': case '7': case '8': case '9':
+ case ':': case ';': case '<': case '=': case '>':
+ case '?':
+ case 'A': case 'B': case 'C': case 'D': case 'E':
+ case 'F': case 'G': case 'H': case 'I': case 'J':
+ case 'K': case 'L': case 'M': case 'N': case 'O':
+ case 'P': case 'Q': case 'R': case 'S': case 'T':
+ case 'U': case 'V': case 'W': case 'X': case 'Y':
+ case 'Z':
+ case '[': case '\\': case ']': case '^': case '_':
+ case 'a': case 'b': case 'c': case 'd': case 'e':
+ case 'f': case 'g': case 'h': case 'i': case 'j':
+ case 'k': case 'l': case 'm': case 'n': case 'o':
+ case 'p': case 'q': case 'r': case 's': case 't':
+ case 'u': case 'v': case 'w': case 'x': case 'y':
+ case 'z': case '{': case '|': case '}': case '~':
+ /* c is in the ISO C "basic character set". */
+ is = isblank_l ((unsigned char) c, locale);
+ if (c == '\t' || c == ' ')
+ ASSERT (is != 0);
+ else
+ ASSERT (is == 0);
+ break;
+ }
}
int
/* POSIX specifies in
<https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap07.html>
no explicit list of control characters. */
- {
- int c;
-
- for (c = 0; c < 0x100; c++)
- switch (c)
- {
- case '\t': case '\v': case '\f':
- case ' ': case '!': case '"': case '#': case '%':
- case '&': case '\'': case '(': case ')': case '*':
- case '+': case ',': case '-': case '.': case '/':
- case '0': case '1': case '2': case '3': case '4':
- case '5': case '6': case '7': case '8': case '9':
- case ':': case ';': case '<': case '=': case '>':
- case '?':
- case 'A': case 'B': case 'C': case 'D': case 'E':
- case 'F': case 'G': case 'H': case 'I': case 'J':
- case 'K': case 'L': case 'M': case 'N': case 'O':
- case 'P': case 'Q': case 'R': case 'S': case 'T':
- case 'U': case 'V': case 'W': case 'X': case 'Y':
- case 'Z':
- case '[': case '\\': case ']': case '^': case '_':
- case 'a': case 'b': case 'c': case 'd': case 'e':
- case 'f': case 'g': case 'h': case 'i': case 'j':
- case 'k': case 'l': case 'm': case 'n': case 'o':
- case 'p': case 'q': case 'r': case 's': case 't':
- case 'u': case 'v': case 'w': case 'x': case 'y':
- case 'z': case '{': case '|': case '}': case '~':
- /* c is in the ISO C "basic character set". */
- is = iscntrl_l ((unsigned char) c, locale);
- switch (c)
- {
- case '\t': case '\v': case '\f':
- ASSERT (is != 0);
- break;
- default:
- ASSERT (is == 0);
- break;
- }
- break;
- }
- }
+ for (int c = 0; c < 0x100; c++)
+ switch (c)
+ {
+ case '\t': case '\v': case '\f':
+ case ' ': case '!': case '"': case '#': case '%':
+ case '&': case '\'': case '(': case ')': case '*':
+ case '+': case ',': case '-': case '.': case '/':
+ case '0': case '1': case '2': case '3': case '4':
+ case '5': case '6': case '7': case '8': case '9':
+ case ':': case ';': case '<': case '=': case '>':
+ case '?':
+ case 'A': case 'B': case 'C': case 'D': case 'E':
+ case 'F': case 'G': case 'H': case 'I': case 'J':
+ case 'K': case 'L': case 'M': case 'N': case 'O':
+ case 'P': case 'Q': case 'R': case 'S': case 'T':
+ case 'U': case 'V': case 'W': case 'X': case 'Y':
+ case 'Z':
+ case '[': case '\\': case ']': case '^': case '_':
+ case 'a': case 'b': case 'c': case 'd': case 'e':
+ case 'f': case 'g': case 'h': case 'i': case 'j':
+ case 'k': case 'l': case 'm': case 'n': case 'o':
+ case 'p': case 'q': case 'r': case 's': case 't':
+ case 'u': case 'v': case 'w': case 'x': case 'y':
+ case 'z': case '{': case '|': case '}': case '~':
+ /* c is in the ISO C "basic character set". */
+ is = iscntrl_l ((unsigned char) c, locale);
+ switch (c)
+ {
+ case '\t': case '\v': case '\f':
+ ASSERT (is != 0);
+ break;
+ default:
+ ASSERT (is == 0);
+ break;
+ }
+ break;
+ }
}
int
/* ISO C 99 sections 7.25.2.1.5 and 5.2.1 specify that the decimal digits
include only the ASCII 0 ... 9 characters. */
- {
- int c;
-
- for (c = 0; c < 0x100; c++)
- switch (c)
- {
- case '\t': case '\v': case '\f':
- case ' ': case '!': case '"': case '#': case '%':
- case '&': case '\'': case '(': case ')': case '*':
- case '+': case ',': case '-': case '.': case '/':
- case '0': case '1': case '2': case '3': case '4':
- case '5': case '6': case '7': case '8': case '9':
- case ':': case ';': case '<': case '=': case '>':
- case '?':
- case 'A': case 'B': case 'C': case 'D': case 'E':
- case 'F': case 'G': case 'H': case 'I': case 'J':
- case 'K': case 'L': case 'M': case 'N': case 'O':
- case 'P': case 'Q': case 'R': case 'S': case 'T':
- case 'U': case 'V': case 'W': case 'X': case 'Y':
- case 'Z':
- case '[': case '\\': case ']': case '^': case '_':
- case 'a': case 'b': case 'c': case 'd': case 'e':
- case 'f': case 'g': case 'h': case 'i': case 'j':
- case 'k': case 'l': case 'm': case 'n': case 'o':
- case 'p': case 'q': case 'r': case 's': case 't':
- case 'u': case 'v': case 'w': case 'x': case 'y':
- case 'z': case '{': case '|': case '}': case '~':
- /* c is in the ISO C "basic character set". */
- is = isdigit_l ((unsigned char) c, locale);
- switch (c)
- {
- case '0': case '1': case '2': case '3': case '4':
- case '5': case '6': case '7': case '8': case '9':
- ASSERT (is != 0);
- break;
- default:
- ASSERT (is == 0);
- break;
- }
- break;
- }
- }
+ for (int c = 0; c < 0x100; c++)
+ switch (c)
+ {
+ case '\t': case '\v': case '\f':
+ case ' ': case '!': case '"': case '#': case '%':
+ case '&': case '\'': case '(': case ')': case '*':
+ case '+': case ',': case '-': case '.': case '/':
+ case '0': case '1': case '2': case '3': case '4':
+ case '5': case '6': case '7': case '8': case '9':
+ case ':': case ';': case '<': case '=': case '>':
+ case '?':
+ case 'A': case 'B': case 'C': case 'D': case 'E':
+ case 'F': case 'G': case 'H': case 'I': case 'J':
+ case 'K': case 'L': case 'M': case 'N': case 'O':
+ case 'P': case 'Q': case 'R': case 'S': case 'T':
+ case 'U': case 'V': case 'W': case 'X': case 'Y':
+ case 'Z':
+ case '[': case '\\': case ']': case '^': case '_':
+ case 'a': case 'b': case 'c': case 'd': case 'e':
+ case 'f': case 'g': case 'h': case 'i': case 'j':
+ case 'k': case 'l': case 'm': case 'n': case 'o':
+ case 'p': case 'q': case 'r': case 's': case 't':
+ case 'u': case 'v': case 'w': case 'x': case 'y':
+ case 'z': case '{': case '|': case '}': case '~':
+ /* c is in the ISO C "basic character set". */
+ is = isdigit_l ((unsigned char) c, locale);
+ switch (c)
+ {
+ case '0': case '1': case '2': case '3': case '4':
+ case '5': case '6': case '7': case '8': case '9':
+ ASSERT (is != 0);
+ break;
+ default:
+ ASSERT (is == 0);
+ break;
+ }
+ break;
+ }
}
int
/* POSIX specifies in
<https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap07.html>
no explicit list of graphic characters. */
- {
- int c;
-
- for (c = 0; c < 0x100; c++)
- switch (c)
- {
- case '\t': case '\v': case '\f':
- case ' ': case '!': case '"': case '#': case '%':
- case '&': case '\'': case '(': case ')': case '*':
- case '+': case ',': case '-': case '.': case '/':
- case '0': case '1': case '2': case '3': case '4':
- case '5': case '6': case '7': case '8': case '9':
- case ':': case ';': case '<': case '=': case '>':
- case '?':
- case 'A': case 'B': case 'C': case 'D': case 'E':
- case 'F': case 'G': case 'H': case 'I': case 'J':
- case 'K': case 'L': case 'M': case 'N': case 'O':
- case 'P': case 'Q': case 'R': case 'S': case 'T':
- case 'U': case 'V': case 'W': case 'X': case 'Y':
- case 'Z':
- case '[': case '\\': case ']': case '^': case '_':
- case 'a': case 'b': case 'c': case 'd': case 'e':
- case 'f': case 'g': case 'h': case 'i': case 'j':
- case 'k': case 'l': case 'm': case 'n': case 'o':
- case 'p': case 'q': case 'r': case 's': case 't':
- case 'u': case 'v': case 'w': case 'x': case 'y':
- case 'z': case '{': case '|': case '}': case '~':
- /* c is in the ISO C "basic character set". */
- is = isgraph_l ((unsigned char) c, locale);
- switch (c)
- {
- case '\t': case '\v': case '\f':
- case ' ':
- ASSERT (is == 0);
- break;
- default:
- ASSERT (is != 0);
- break;
- }
- break;
- }
- }
+ for (int c = 0; c < 0x100; c++)
+ switch (c)
+ {
+ case '\t': case '\v': case '\f':
+ case ' ': case '!': case '"': case '#': case '%':
+ case '&': case '\'': case '(': case ')': case '*':
+ case '+': case ',': case '-': case '.': case '/':
+ case '0': case '1': case '2': case '3': case '4':
+ case '5': case '6': case '7': case '8': case '9':
+ case ':': case ';': case '<': case '=': case '>':
+ case '?':
+ case 'A': case 'B': case 'C': case 'D': case 'E':
+ case 'F': case 'G': case 'H': case 'I': case 'J':
+ case 'K': case 'L': case 'M': case 'N': case 'O':
+ case 'P': case 'Q': case 'R': case 'S': case 'T':
+ case 'U': case 'V': case 'W': case 'X': case 'Y':
+ case 'Z':
+ case '[': case '\\': case ']': case '^': case '_':
+ case 'a': case 'b': case 'c': case 'd': case 'e':
+ case 'f': case 'g': case 'h': case 'i': case 'j':
+ case 'k': case 'l': case 'm': case 'n': case 'o':
+ case 'p': case 'q': case 'r': case 's': case 't':
+ case 'u': case 'v': case 'w': case 'x': case 'y':
+ case 'z': case '{': case '|': case '}': case '~':
+ /* c is in the ISO C "basic character set". */
+ is = isgraph_l ((unsigned char) c, locale);
+ switch (c)
+ {
+ case '\t': case '\v': case '\f':
+ case ' ':
+ ASSERT (is == 0);
+ break;
+ default:
+ ASSERT (is != 0);
+ break;
+ }
+ break;
+ }
}
int
- in the "POSIX" locale (which is usually the same as the "C" locale),
the lowercase characters include only the ASCII a ... z characters.
*/
- {
- int c;
-
- for (c = 0; c < 0x100; c++)
- switch (c)
- {
- case '\t': case '\v': case '\f':
- case ' ': case '!': case '"': case '#': case '%':
- case '&': case '\'': case '(': case ')': case '*':
- case '+': case ',': case '-': case '.': case '/':
- case '0': case '1': case '2': case '3': case '4':
- case '5': case '6': case '7': case '8': case '9':
- case ':': case ';': case '<': case '=': case '>':
- case '?':
- case 'A': case 'B': case 'C': case 'D': case 'E':
- case 'F': case 'G': case 'H': case 'I': case 'J':
- case 'K': case 'L': case 'M': case 'N': case 'O':
- case 'P': case 'Q': case 'R': case 'S': case 'T':
- case 'U': case 'V': case 'W': case 'X': case 'Y':
- case 'Z':
- case '[': case '\\': case ']': case '^': case '_':
- case 'a': case 'b': case 'c': case 'd': case 'e':
- case 'f': case 'g': case 'h': case 'i': case 'j':
- case 'k': case 'l': case 'm': case 'n': case 'o':
- case 'p': case 'q': case 'r': case 's': case 't':
- case 'u': case 'v': case 'w': case 'x': case 'y':
- case 'z': case '{': case '|': case '}': case '~':
- /* c is in the ISO C "basic character set". */
- is = islower_l ((unsigned char) c, locale);
- switch (c)
- {
- case 'a': case 'b': case 'c': case 'd': case 'e':
- case 'f': case 'g': case 'h': case 'i': case 'j':
- case 'k': case 'l': case 'm': case 'n': case 'o':
- case 'p': case 'q': case 'r': case 's': case 't':
- case 'u': case 'v': case 'w': case 'x': case 'y':
- case 'z':
- ASSERT (is != 0);
- break;
- default:
- ASSERT (is == 0);
- break;
- }
- break;
- }
- }
+ for (int c = 0; c < 0x100; c++)
+ switch (c)
+ {
+ case '\t': case '\v': case '\f':
+ case ' ': case '!': case '"': case '#': case '%':
+ case '&': case '\'': case '(': case ')': case '*':
+ case '+': case ',': case '-': case '.': case '/':
+ case '0': case '1': case '2': case '3': case '4':
+ case '5': case '6': case '7': case '8': case '9':
+ case ':': case ';': case '<': case '=': case '>':
+ case '?':
+ case 'A': case 'B': case 'C': case 'D': case 'E':
+ case 'F': case 'G': case 'H': case 'I': case 'J':
+ case 'K': case 'L': case 'M': case 'N': case 'O':
+ case 'P': case 'Q': case 'R': case 'S': case 'T':
+ case 'U': case 'V': case 'W': case 'X': case 'Y':
+ case 'Z':
+ case '[': case '\\': case ']': case '^': case '_':
+ case 'a': case 'b': case 'c': case 'd': case 'e':
+ case 'f': case 'g': case 'h': case 'i': case 'j':
+ case 'k': case 'l': case 'm': case 'n': case 'o':
+ case 'p': case 'q': case 'r': case 's': case 't':
+ case 'u': case 'v': case 'w': case 'x': case 'y':
+ case 'z': case '{': case '|': case '}': case '~':
+ /* c is in the ISO C "basic character set". */
+ is = islower_l ((unsigned char) c, locale);
+ switch (c)
+ {
+ case 'a': case 'b': case 'c': case 'd': case 'e':
+ case 'f': case 'g': case 'h': case 'i': case 'j':
+ case 'k': case 'l': case 'm': case 'n': case 'o':
+ case 'p': case 'q': case 'r': case 's': case 't':
+ case 'u': case 'v': case 'w': case 'x': case 'y':
+ case 'z':
+ ASSERT (is != 0);
+ break;
+ default:
+ ASSERT (is == 0);
+ break;
+ }
+ break;
+ }
}
int
/* POSIX specifies in
<https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap07.html>
no explicit list of printable characters. */
- {
- int c;
-
- for (c = 0; c < 0x100; c++)
- switch (c)
- {
- case '\t': case '\v': case '\f':
- case ' ': case '!': case '"': case '#': case '%':
- case '&': case '\'': case '(': case ')': case '*':
- case '+': case ',': case '-': case '.': case '/':
- case '0': case '1': case '2': case '3': case '4':
- case '5': case '6': case '7': case '8': case '9':
- case ':': case ';': case '<': case '=': case '>':
- case '?':
- case 'A': case 'B': case 'C': case 'D': case 'E':
- case 'F': case 'G': case 'H': case 'I': case 'J':
- case 'K': case 'L': case 'M': case 'N': case 'O':
- case 'P': case 'Q': case 'R': case 'S': case 'T':
- case 'U': case 'V': case 'W': case 'X': case 'Y':
- case 'Z':
- case '[': case '\\': case ']': case '^': case '_':
- case 'a': case 'b': case 'c': case 'd': case 'e':
- case 'f': case 'g': case 'h': case 'i': case 'j':
- case 'k': case 'l': case 'm': case 'n': case 'o':
- case 'p': case 'q': case 'r': case 's': case 't':
- case 'u': case 'v': case 'w': case 'x': case 'y':
- case 'z': case '{': case '|': case '}': case '~':
- /* c is in the ISO C "basic character set". */
- is = isprint_l ((unsigned char) c, locale);
- switch (c)
- {
- case '\t': case '\v': case '\f':
- ASSERT (is == 0);
- break;
- default:
- ASSERT (is != 0);
- break;
- }
- break;
- }
- }
+ for (int c = 0; c < 0x100; c++)
+ switch (c)
+ {
+ case '\t': case '\v': case '\f':
+ case ' ': case '!': case '"': case '#': case '%':
+ case '&': case '\'': case '(': case ')': case '*':
+ case '+': case ',': case '-': case '.': case '/':
+ case '0': case '1': case '2': case '3': case '4':
+ case '5': case '6': case '7': case '8': case '9':
+ case ':': case ';': case '<': case '=': case '>':
+ case '?':
+ case 'A': case 'B': case 'C': case 'D': case 'E':
+ case 'F': case 'G': case 'H': case 'I': case 'J':
+ case 'K': case 'L': case 'M': case 'N': case 'O':
+ case 'P': case 'Q': case 'R': case 'S': case 'T':
+ case 'U': case 'V': case 'W': case 'X': case 'Y':
+ case 'Z':
+ case '[': case '\\': case ']': case '^': case '_':
+ case 'a': case 'b': case 'c': case 'd': case 'e':
+ case 'f': case 'g': case 'h': case 'i': case 'j':
+ case 'k': case 'l': case 'm': case 'n': case 'o':
+ case 'p': case 'q': case 'r': case 's': case 't':
+ case 'u': case 'v': case 'w': case 'x': case 'y':
+ case 'z': case '{': case '|': case '}': case '~':
+ /* c is in the ISO C "basic character set". */
+ is = isprint_l ((unsigned char) c, locale);
+ switch (c)
+ {
+ case '\t': case '\v': case '\f':
+ ASSERT (is == 0);
+ break;
+ default:
+ ASSERT (is != 0);
+ break;
+ }
+ break;
+ }
}
int
/* POSIX specifies in
<https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap07.html>
no explicit list of punctuation or symbol characters. */
- {
- int c;
-
- for (c = 0; c < 0x100; c++)
- switch (c)
- {
- case '\t': case '\v': case '\f':
- case ' ': case '!': case '"': case '#': case '%':
- case '&': case '\'': case '(': case ')': case '*':
- case '+': case ',': case '-': case '.': case '/':
- case '0': case '1': case '2': case '3': case '4':
- case '5': case '6': case '7': case '8': case '9':
- case ':': case ';': case '<': case '=': case '>':
- case '?':
- case 'A': case 'B': case 'C': case 'D': case 'E':
- case 'F': case 'G': case 'H': case 'I': case 'J':
- case 'K': case 'L': case 'M': case 'N': case 'O':
- case 'P': case 'Q': case 'R': case 'S': case 'T':
- case 'U': case 'V': case 'W': case 'X': case 'Y':
- case 'Z':
- case '[': case '\\': case ']': case '^': case '_':
- case 'a': case 'b': case 'c': case 'd': case 'e':
- case 'f': case 'g': case 'h': case 'i': case 'j':
- case 'k': case 'l': case 'm': case 'n': case 'o':
- case 'p': case 'q': case 'r': case 's': case 't':
- case 'u': case 'v': case 'w': case 'x': case 'y':
- case 'z': case '{': case '|': case '}': case '~':
- /* c is in the ISO C "basic character set". */
- is = ispunct_l ((unsigned char) c, locale);
- switch (c)
- {
- case ' ':
- case '0': case '1': case '2': case '3': case '4':
- case '5': case '6': case '7': case '8': case '9':
- case 'A': case 'B': case 'C': case 'D': case 'E':
- case 'F': case 'G': case 'H': case 'I': case 'J':
- case 'K': case 'L': case 'M': case 'N': case 'O':
- case 'P': case 'Q': case 'R': case 'S': case 'T':
- case 'U': case 'V': case 'W': case 'X': case 'Y':
- case 'Z':
- case 'a': case 'b': case 'c': case 'd': case 'e':
- case 'f': case 'g': case 'h': case 'i': case 'j':
- case 'k': case 'l': case 'm': case 'n': case 'o':
- case 'p': case 'q': case 'r': case 's': case 't':
- case 'u': case 'v': case 'w': case 'x': case 'y':
- case 'z':
- /* c is an alphanumeric or space character. */
- ASSERT (is == 0);
- break;
- case '!': case '"': case '#': case '%':
- case '&': case '\'': case '(': case ')': case '*':
- case '+': case ',': case '-': case '.': case '/':
- case ':': case ';': case '<': case '=': case '>':
- case '?':
- case '[': case '\\': case ']': case '^': case '_':
- case '{': case '|': case '}': case '~':
- /* These characters are usually expected to be punctuation or
- symbol characters. */
- ASSERT (is != 0);
- break;
- default:
- ASSERT (is == 0);
- break;
- }
- break;
- }
- }
+ for (int c = 0; c < 0x100; c++)
+ switch (c)
+ {
+ case '\t': case '\v': case '\f':
+ case ' ': case '!': case '"': case '#': case '%':
+ case '&': case '\'': case '(': case ')': case '*':
+ case '+': case ',': case '-': case '.': case '/':
+ case '0': case '1': case '2': case '3': case '4':
+ case '5': case '6': case '7': case '8': case '9':
+ case ':': case ';': case '<': case '=': case '>':
+ case '?':
+ case 'A': case 'B': case 'C': case 'D': case 'E':
+ case 'F': case 'G': case 'H': case 'I': case 'J':
+ case 'K': case 'L': case 'M': case 'N': case 'O':
+ case 'P': case 'Q': case 'R': case 'S': case 'T':
+ case 'U': case 'V': case 'W': case 'X': case 'Y':
+ case 'Z':
+ case '[': case '\\': case ']': case '^': case '_':
+ case 'a': case 'b': case 'c': case 'd': case 'e':
+ case 'f': case 'g': case 'h': case 'i': case 'j':
+ case 'k': case 'l': case 'm': case 'n': case 'o':
+ case 'p': case 'q': case 'r': case 's': case 't':
+ case 'u': case 'v': case 'w': case 'x': case 'y':
+ case 'z': case '{': case '|': case '}': case '~':
+ /* c is in the ISO C "basic character set". */
+ is = ispunct_l ((unsigned char) c, locale);
+ switch (c)
+ {
+ case ' ':
+ case '0': case '1': case '2': case '3': case '4':
+ case '5': case '6': case '7': case '8': case '9':
+ case 'A': case 'B': case 'C': case 'D': case 'E':
+ case 'F': case 'G': case 'H': case 'I': case 'J':
+ case 'K': case 'L': case 'M': case 'N': case 'O':
+ case 'P': case 'Q': case 'R': case 'S': case 'T':
+ case 'U': case 'V': case 'W': case 'X': case 'Y':
+ case 'Z':
+ case 'a': case 'b': case 'c': case 'd': case 'e':
+ case 'f': case 'g': case 'h': case 'i': case 'j':
+ case 'k': case 'l': case 'm': case 'n': case 'o':
+ case 'p': case 'q': case 'r': case 's': case 't':
+ case 'u': case 'v': case 'w': case 'x': case 'y':
+ case 'z':
+ /* c is an alphanumeric or space character. */
+ ASSERT (is == 0);
+ break;
+ case '!': case '"': case '#': case '%':
+ case '&': case '\'': case '(': case ')': case '*':
+ case '+': case ',': case '-': case '.': case '/':
+ case ':': case ';': case '<': case '=': case '>':
+ case '?':
+ case '[': case '\\': case ']': case '^': case '_':
+ case '{': case '|': case '}': case '~':
+ /* These characters are usually expected to be punctuation or
+ symbol characters. */
+ ASSERT (is != 0);
+ break;
+ default:
+ ASSERT (is == 0);
+ break;
+ }
+ break;
+ }
}
int
- in the "POSIX" locale (which is usually the same as the "C" locale),
the white-space characters include only the ASCII <space>, <form-feed>,
<newline>, <carriage-return>, <tab>, <vertical-tab> characters. */
- {
- int c;
-
- for (c = 0; c < 0x100; c++)
- switch (c)
- {
- case '\f': case '\n': case '\r': case '\t': case '\v':
- case ' ': case '!': case '"': case '#': case '%':
- case '&': case '\'': case '(': case ')': case '*':
- case '+': case ',': case '-': case '.': case '/':
- case '0': case '1': case '2': case '3': case '4':
- case '5': case '6': case '7': case '8': case '9':
- case ':': case ';': case '<': case '=': case '>':
- case '?':
- case 'A': case 'B': case 'C': case 'D': case 'E':
- case 'F': case 'G': case 'H': case 'I': case 'J':
- case 'K': case 'L': case 'M': case 'N': case 'O':
- case 'P': case 'Q': case 'R': case 'S': case 'T':
- case 'U': case 'V': case 'W': case 'X': case 'Y':
- case 'Z':
- case '[': case '\\': case ']': case '^': case '_':
- case 'a': case 'b': case 'c': case 'd': case 'e':
- case 'f': case 'g': case 'h': case 'i': case 'j':
- case 'k': case 'l': case 'm': case 'n': case 'o':
- case 'p': case 'q': case 'r': case 's': case 't':
- case 'u': case 'v': case 'w': case 'x': case 'y':
- case 'z': case '{': case '|': case '}': case '~':
- /* c is in the ISO C "basic character set" or one of the explicitly
- mentioned white-space characters. */
- is = isspace_l ((unsigned char) c, locale);
- switch (c)
- {
- case ' ': case '\f': case '\n': case '\r': case '\t': case '\v':
- ASSERT (is != 0);
- break;
- default:
- ASSERT (is == 0);
- break;
- }
- break;
- }
- }
+ for (int c = 0; c < 0x100; c++)
+ switch (c)
+ {
+ case '\f': case '\n': case '\r': case '\t': case '\v':
+ case ' ': case '!': case '"': case '#': case '%':
+ case '&': case '\'': case '(': case ')': case '*':
+ case '+': case ',': case '-': case '.': case '/':
+ case '0': case '1': case '2': case '3': case '4':
+ case '5': case '6': case '7': case '8': case '9':
+ case ':': case ';': case '<': case '=': case '>':
+ case '?':
+ case 'A': case 'B': case 'C': case 'D': case 'E':
+ case 'F': case 'G': case 'H': case 'I': case 'J':
+ case 'K': case 'L': case 'M': case 'N': case 'O':
+ case 'P': case 'Q': case 'R': case 'S': case 'T':
+ case 'U': case 'V': case 'W': case 'X': case 'Y':
+ case 'Z':
+ case '[': case '\\': case ']': case '^': case '_':
+ case 'a': case 'b': case 'c': case 'd': case 'e':
+ case 'f': case 'g': case 'h': case 'i': case 'j':
+ case 'k': case 'l': case 'm': case 'n': case 'o':
+ case 'p': case 'q': case 'r': case 's': case 't':
+ case 'u': case 'v': case 'w': case 'x': case 'y':
+ case 'z': case '{': case '|': case '}': case '~':
+ /* c is in the ISO C "basic character set" or one of the explicitly
+ mentioned white-space characters. */
+ is = isspace_l ((unsigned char) c, locale);
+ switch (c)
+ {
+ case ' ': case '\f': case '\n': case '\r': case '\t': case '\v':
+ ASSERT (is != 0);
+ break;
+ default:
+ ASSERT (is == 0);
+ break;
+ }
+ break;
+ }
}
int
- in the "POSIX" locale (which is usually the same as the "C" locale),
the uppercase characters include only the ASCII A ... Z characters.
*/
- {
- int c;
-
- for (c = 0; c < 0x100; c++)
- switch (c)
- {
- case '\t': case '\v': case '\f':
- case ' ': case '!': case '"': case '#': case '%':
- case '&': case '\'': case '(': case ')': case '*':
- case '+': case ',': case '-': case '.': case '/':
- case '0': case '1': case '2': case '3': case '4':
- case '5': case '6': case '7': case '8': case '9':
- case ':': case ';': case '<': case '=': case '>':
- case '?':
- case 'A': case 'B': case 'C': case 'D': case 'E':
- case 'F': case 'G': case 'H': case 'I': case 'J':
- case 'K': case 'L': case 'M': case 'N': case 'O':
- case 'P': case 'Q': case 'R': case 'S': case 'T':
- case 'U': case 'V': case 'W': case 'X': case 'Y':
- case 'Z':
- case '[': case '\\': case ']': case '^': case '_':
- case 'a': case 'b': case 'c': case 'd': case 'e':
- case 'f': case 'g': case 'h': case 'i': case 'j':
- case 'k': case 'l': case 'm': case 'n': case 'o':
- case 'p': case 'q': case 'r': case 's': case 't':
- case 'u': case 'v': case 'w': case 'x': case 'y':
- case 'z': case '{': case '|': case '}': case '~':
- /* c is in the ISO C "basic character set". */
- is = isupper_l ((unsigned char) c, locale);
- switch (c)
- {
- case 'A': case 'B': case 'C': case 'D': case 'E':
- case 'F': case 'G': case 'H': case 'I': case 'J':
- case 'K': case 'L': case 'M': case 'N': case 'O':
- case 'P': case 'Q': case 'R': case 'S': case 'T':
- case 'U': case 'V': case 'W': case 'X': case 'Y':
- case 'Z':
- ASSERT (is != 0);
- break;
- default:
- ASSERT (is == 0);
- break;
- }
- break;
- }
- }
+ for (int c = 0; c < 0x100; c++)
+ switch (c)
+ {
+ case '\t': case '\v': case '\f':
+ case ' ': case '!': case '"': case '#': case '%':
+ case '&': case '\'': case '(': case ')': case '*':
+ case '+': case ',': case '-': case '.': case '/':
+ case '0': case '1': case '2': case '3': case '4':
+ case '5': case '6': case '7': case '8': case '9':
+ case ':': case ';': case '<': case '=': case '>':
+ case '?':
+ case 'A': case 'B': case 'C': case 'D': case 'E':
+ case 'F': case 'G': case 'H': case 'I': case 'J':
+ case 'K': case 'L': case 'M': case 'N': case 'O':
+ case 'P': case 'Q': case 'R': case 'S': case 'T':
+ case 'U': case 'V': case 'W': case 'X': case 'Y':
+ case 'Z':
+ case '[': case '\\': case ']': case '^': case '_':
+ case 'a': case 'b': case 'c': case 'd': case 'e':
+ case 'f': case 'g': case 'h': case 'i': case 'j':
+ case 'k': case 'l': case 'm': case 'n': case 'o':
+ case 'p': case 'q': case 'r': case 's': case 't':
+ case 'u': case 'v': case 'w': case 'x': case 'y':
+ case 'z': case '{': case '|': case '}': case '~':
+ /* c is in the ISO C "basic character set". */
+ is = isupper_l ((unsigned char) c, locale);
+ switch (c)
+ {
+ case 'A': case 'B': case 'C': case 'D': case 'E':
+ case 'F': case 'G': case 'H': case 'I': case 'J':
+ case 'K': case 'L': case 'M': case 'N': case 'O':
+ case 'P': case 'Q': case 'R': case 'S': case 'T':
+ case 'U': case 'V': case 'W': case 'X': case 'Y':
+ case 'Z':
+ ASSERT (is != 0);
+ break;
+ default:
+ ASSERT (is == 0);
+ break;
+ }
+ break;
+ }
}
int
/* Test single-byte characters.
ISO C 99 sections 7.25.2.1.5 and 5.2.1 specify that the decimal digits
include only the ASCII 0 ... 9 characters. */
- {
- int c;
-
- for (c = 0; c < 0x100; c++)
- switch (c)
- {
- case '\t': case '\v': case '\f':
- case ' ': case '!': case '"': case '#': case '%':
- case '&': case '\'': case '(': case ')': case '*':
- case '+': case ',': case '-': case '.': case '/':
- case '0': case '1': case '2': case '3': case '4':
- case '5': case '6': case '7': case '8': case '9':
- case ':': case ';': case '<': case '=': case '>':
- case '?':
- case 'A': case 'B': case 'C': case 'D': case 'E':
- case 'F': case 'G': case 'H': case 'I': case 'J':
- case 'K': case 'L': case 'M': case 'N': case 'O':
- case 'P': case 'Q': case 'R': case 'S': case 'T':
- case 'U': case 'V': case 'W': case 'X': case 'Y':
- case 'Z':
- case '[': case '\\': case ']': case '^': case '_':
- case 'a': case 'b': case 'c': case 'd': case 'e':
- case 'f': case 'g': case 'h': case 'i': case 'j':
- case 'k': case 'l': case 'm': case 'n': case 'o':
- case 'p': case 'q': case 'r': case 's': case 't':
- case 'u': case 'v': case 'w': case 'x': case 'y':
- case 'z': case '{': case '|': case '}': case '~':
- /* c is in the ISO C "basic character set". */
- buf[0] = (unsigned char) c;
- is = for_character (buf, 1);
- switch (c)
- {
- case '0': case '1': case '2': case '3': case '4':
- case '5': case '6': case '7': case '8': case '9':
- ASSERT (is != 0);
- break;
- default:
- ASSERT (is == 0);
- break;
- }
- break;
- }
- }
+ for (int c = 0; c < 0x100; c++)
+ switch (c)
+ {
+ case '\t': case '\v': case '\f':
+ case ' ': case '!': case '"': case '#': case '%':
+ case '&': case '\'': case '(': case ')': case '*':
+ case '+': case ',': case '-': case '.': case '/':
+ case '0': case '1': case '2': case '3': case '4':
+ case '5': case '6': case '7': case '8': case '9':
+ case ':': case ';': case '<': case '=': case '>':
+ case '?':
+ case 'A': case 'B': case 'C': case 'D': case 'E':
+ case 'F': case 'G': case 'H': case 'I': case 'J':
+ case 'K': case 'L': case 'M': case 'N': case 'O':
+ case 'P': case 'Q': case 'R': case 'S': case 'T':
+ case 'U': case 'V': case 'W': case 'X': case 'Y':
+ case 'Z':
+ case '[': case '\\': case ']': case '^': case '_':
+ case 'a': case 'b': case 'c': case 'd': case 'e':
+ case 'f': case 'g': case 'h': case 'i': case 'j':
+ case 'k': case 'l': case 'm': case 'n': case 'o':
+ case 'p': case 'q': case 'r': case 's': case 't':
+ case 'u': case 'v': case 'w': case 'x': case 'y':
+ case 'z': case '{': case '|': case '}': case '~':
+ /* c is in the ISO C "basic character set". */
+ buf[0] = (unsigned char) c;
+ is = for_character (buf, 1);
+ switch (c)
+ {
+ case '0': case '1': case '2': case '3': case '4':
+ case '5': case '6': case '7': case '8': case '9':
+ ASSERT (is != 0);
+ break;
+ default:
+ ASSERT (is == 0);
+ break;
+ }
+ break;
+ }
if (argc > 1)
switch (argv[1][0])
POSIX specifies in
<https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap07.html>
no explicit list of punctuation or symbol characters. */
- {
- int c;
-
- for (c = 0; c < 0x100; c++)
- switch (c)
- {
- case '\t': case '\v': case '\f':
- case ' ': case '!': case '"': case '#': case '%':
- case '&': case '\'': case '(': case ')': case '*':
- case '+': case ',': case '-': case '.': case '/':
- case '0': case '1': case '2': case '3': case '4':
- case '5': case '6': case '7': case '8': case '9':
- case ':': case ';': case '<': case '=': case '>':
- case '?':
- case 'A': case 'B': case 'C': case 'D': case 'E':
- case 'F': case 'G': case 'H': case 'I': case 'J':
- case 'K': case 'L': case 'M': case 'N': case 'O':
- case 'P': case 'Q': case 'R': case 'S': case 'T':
- case 'U': case 'V': case 'W': case 'X': case 'Y':
- case 'Z':
- case '[': case '\\': case ']': case '^': case '_':
- case 'a': case 'b': case 'c': case 'd': case 'e':
- case 'f': case 'g': case 'h': case 'i': case 'j':
- case 'k': case 'l': case 'm': case 'n': case 'o':
- case 'p': case 'q': case 'r': case 's': case 't':
- case 'u': case 'v': case 'w': case 'x': case 'y':
- case 'z': case '{': case '|': case '}': case '~':
- /* c is in the ISO C "basic character set". */
- buf[0] = (unsigned char) c;
- is = for_character (buf, 1);
- switch (c)
- {
- case ' ':
- case '0': case '1': case '2': case '3': case '4':
- case '5': case '6': case '7': case '8': case '9':
- case 'A': case 'B': case 'C': case 'D': case 'E':
- case 'F': case 'G': case 'H': case 'I': case 'J':
- case 'K': case 'L': case 'M': case 'N': case 'O':
- case 'P': case 'Q': case 'R': case 'S': case 'T':
- case 'U': case 'V': case 'W': case 'X': case 'Y':
- case 'Z':
- case 'a': case 'b': case 'c': case 'd': case 'e':
- case 'f': case 'g': case 'h': case 'i': case 'j':
- case 'k': case 'l': case 'm': case 'n': case 'o':
- case 'p': case 'q': case 'r': case 's': case 't':
- case 'u': case 'v': case 'w': case 'x': case 'y':
- case 'z':
- /* c is an alphanumeric or space character. */
- ASSERT (is == 0);
- break;
- case '!': case '"': case '#': case '%':
- case '&': case '\'': case '(': case ')': case '*':
- case '+': case ',': case '-': case '.': case '/':
- case ':': case ';': case '<': case '=': case '>':
- case '?':
- case '[': case '\\': case ']': case '^': case '_':
- case '{': case '|': case '}': case '~':
- /* These characters are usually expected to be punctuation or
- symbol characters. */
- ASSERT (is != 0);
- break;
- default:
- ASSERT (is == 0);
- break;
- }
- break;
- }
- }
+ for (int c = 0; c < 0x100; c++)
+ switch (c)
+ {
+ case '\t': case '\v': case '\f':
+ case ' ': case '!': case '"': case '#': case '%':
+ case '&': case '\'': case '(': case ')': case '*':
+ case '+': case ',': case '-': case '.': case '/':
+ case '0': case '1': case '2': case '3': case '4':
+ case '5': case '6': case '7': case '8': case '9':
+ case ':': case ';': case '<': case '=': case '>':
+ case '?':
+ case 'A': case 'B': case 'C': case 'D': case 'E':
+ case 'F': case 'G': case 'H': case 'I': case 'J':
+ case 'K': case 'L': case 'M': case 'N': case 'O':
+ case 'P': case 'Q': case 'R': case 'S': case 'T':
+ case 'U': case 'V': case 'W': case 'X': case 'Y':
+ case 'Z':
+ case '[': case '\\': case ']': case '^': case '_':
+ case 'a': case 'b': case 'c': case 'd': case 'e':
+ case 'f': case 'g': case 'h': case 'i': case 'j':
+ case 'k': case 'l': case 'm': case 'n': case 'o':
+ case 'p': case 'q': case 'r': case 's': case 't':
+ case 'u': case 'v': case 'w': case 'x': case 'y':
+ case 'z': case '{': case '|': case '}': case '~':
+ /* c is in the ISO C "basic character set". */
+ buf[0] = (unsigned char) c;
+ is = for_character (buf, 1);
+ switch (c)
+ {
+ case ' ':
+ case '0': case '1': case '2': case '3': case '4':
+ case '5': case '6': case '7': case '8': case '9':
+ case 'A': case 'B': case 'C': case 'D': case 'E':
+ case 'F': case 'G': case 'H': case 'I': case 'J':
+ case 'K': case 'L': case 'M': case 'N': case 'O':
+ case 'P': case 'Q': case 'R': case 'S': case 'T':
+ case 'U': case 'V': case 'W': case 'X': case 'Y':
+ case 'Z':
+ case 'a': case 'b': case 'c': case 'd': case 'e':
+ case 'f': case 'g': case 'h': case 'i': case 'j':
+ case 'k': case 'l': case 'm': case 'n': case 'o':
+ case 'p': case 'q': case 'r': case 's': case 't':
+ case 'u': case 'v': case 'w': case 'x': case 'y':
+ case 'z':
+ /* c is an alphanumeric or space character. */
+ ASSERT (is == 0);
+ break;
+ case '!': case '"': case '#': case '%':
+ case '&': case '\'': case '(': case ')': case '*':
+ case '+': case ',': case '-': case '.': case '/':
+ case ':': case ';': case '<': case '=': case '>':
+ case '?':
+ case '[': case '\\': case ']': case '^': case '_':
+ case '{': case '|': case '}': case '~':
+ /* These characters are usually expected to be punctuation or
+ symbol characters. */
+ ASSERT (is != 0);
+ break;
+ default:
+ ASSERT (is == 0);
+ break;
+ }
+ break;
+ }
if (argc > 1)
switch (argv[1][0])
/* Test single-byte characters.
ISO C 99 sections 7.25.2.1.12 and 6.4.4.1 specify that the hexadecimal
digits include only the ASCII 0 ... 9 A ... F a ... f characters. */
- {
- int c;
-
- for (c = 0; c < 0x100; c++)
- switch (c)
- {
- case '\t': case '\v': case '\f':
- case ' ': case '!': case '"': case '#': case '%':
- case '&': case '\'': case '(': case ')': case '*':
- case '+': case ',': case '-': case '.': case '/':
- case '0': case '1': case '2': case '3': case '4':
- case '5': case '6': case '7': case '8': case '9':
- case ':': case ';': case '<': case '=': case '>':
- case '?':
- case 'A': case 'B': case 'C': case 'D': case 'E':
- case 'F': case 'G': case 'H': case 'I': case 'J':
- case 'K': case 'L': case 'M': case 'N': case 'O':
- case 'P': case 'Q': case 'R': case 'S': case 'T':
- case 'U': case 'V': case 'W': case 'X': case 'Y':
- case 'Z':
- case '[': case '\\': case ']': case '^': case '_':
- case 'a': case 'b': case 'c': case 'd': case 'e':
- case 'f': case 'g': case 'h': case 'i': case 'j':
- case 'k': case 'l': case 'm': case 'n': case 'o':
- case 'p': case 'q': case 'r': case 's': case 't':
- case 'u': case 'v': case 'w': case 'x': case 'y':
- case 'z': case '{': case '|': case '}': case '~':
- /* c is in the ISO C "basic character set". */
- buf[0] = (unsigned char) c;
- is = for_character (buf, 1);
- switch (c)
- {
- case '0': case '1': case '2': case '3': case '4':
- case '5': case '6': case '7': case '8': case '9':
- case 'A': case 'B': case 'C': case 'D': case 'E': case 'F':
- case 'a': case 'b': case 'c': case 'd': case 'e': case 'f':
- ASSERT (is != 0);
- break;
- default:
- ASSERT (is == 0);
- break;
- }
- break;
- }
- }
+ for (int c = 0; c < 0x100; c++)
+ switch (c)
+ {
+ case '\t': case '\v': case '\f':
+ case ' ': case '!': case '"': case '#': case '%':
+ case '&': case '\'': case '(': case ')': case '*':
+ case '+': case ',': case '-': case '.': case '/':
+ case '0': case '1': case '2': case '3': case '4':
+ case '5': case '6': case '7': case '8': case '9':
+ case ':': case ';': case '<': case '=': case '>':
+ case '?':
+ case 'A': case 'B': case 'C': case 'D': case 'E':
+ case 'F': case 'G': case 'H': case 'I': case 'J':
+ case 'K': case 'L': case 'M': case 'N': case 'O':
+ case 'P': case 'Q': case 'R': case 'S': case 'T':
+ case 'U': case 'V': case 'W': case 'X': case 'Y':
+ case 'Z':
+ case '[': case '\\': case ']': case '^': case '_':
+ case 'a': case 'b': case 'c': case 'd': case 'e':
+ case 'f': case 'g': case 'h': case 'i': case 'j':
+ case 'k': case 'l': case 'm': case 'n': case 'o':
+ case 'p': case 'q': case 'r': case 's': case 't':
+ case 'u': case 'v': case 'w': case 'x': case 'y':
+ case 'z': case '{': case '|': case '}': case '~':
+ /* c is in the ISO C "basic character set". */
+ buf[0] = (unsigned char) c;
+ is = for_character (buf, 1);
+ switch (c)
+ {
+ case '0': case '1': case '2': case '3': case '4':
+ case '5': case '6': case '7': case '8': case '9':
+ case 'A': case 'B': case 'C': case 'D': case 'E': case 'F':
+ case 'a': case 'b': case 'c': case 'd': case 'e': case 'f':
+ ASSERT (is != 0);
+ break;
+ default:
+ ASSERT (is == 0);
+ break;
+ }
+ break;
+ }
if (argc > 1)
switch (argv[1][0])
/* ISO C 99 sections 7.25.2.1.12 and 6.4.4.1 specify that the hexadecimal
digits include only the ASCII 0 ... 9 A ... F a ... f characters. */
- {
- int c;
-
- for (c = 0; c < 0x100; c++)
- switch (c)
- {
- case '\t': case '\v': case '\f':
- case ' ': case '!': case '"': case '#': case '%':
- case '&': case '\'': case '(': case ')': case '*':
- case '+': case ',': case '-': case '.': case '/':
- case '0': case '1': case '2': case '3': case '4':
- case '5': case '6': case '7': case '8': case '9':
- case ':': case ';': case '<': case '=': case '>':
- case '?':
- case 'A': case 'B': case 'C': case 'D': case 'E':
- case 'F': case 'G': case 'H': case 'I': case 'J':
- case 'K': case 'L': case 'M': case 'N': case 'O':
- case 'P': case 'Q': case 'R': case 'S': case 'T':
- case 'U': case 'V': case 'W': case 'X': case 'Y':
- case 'Z':
- case '[': case '\\': case ']': case '^': case '_':
- case 'a': case 'b': case 'c': case 'd': case 'e':
- case 'f': case 'g': case 'h': case 'i': case 'j':
- case 'k': case 'l': case 'm': case 'n': case 'o':
- case 'p': case 'q': case 'r': case 's': case 't':
- case 'u': case 'v': case 'w': case 'x': case 'y':
- case 'z': case '{': case '|': case '}': case '~':
- /* c is in the ISO C "basic character set". */
- is = isxdigit_l ((unsigned char) c, locale);
- switch (c)
- {
- case '0': case '1': case '2': case '3': case '4':
- case '5': case '6': case '7': case '8': case '9':
- case 'A': case 'B': case 'C': case 'D': case 'E': case 'F':
- case 'a': case 'b': case 'c': case 'd': case 'e': case 'f':
- ASSERT (is != 0);
- break;
- default:
- ASSERT (is == 0);
- break;
- }
- break;
- }
- }
+ for (int c = 0; c < 0x100; c++)
+ switch (c)
+ {
+ case '\t': case '\v': case '\f':
+ case ' ': case '!': case '"': case '#': case '%':
+ case '&': case '\'': case '(': case ')': case '*':
+ case '+': case ',': case '-': case '.': case '/':
+ case '0': case '1': case '2': case '3': case '4':
+ case '5': case '6': case '7': case '8': case '9':
+ case ':': case ';': case '<': case '=': case '>':
+ case '?':
+ case 'A': case 'B': case 'C': case 'D': case 'E':
+ case 'F': case 'G': case 'H': case 'I': case 'J':
+ case 'K': case 'L': case 'M': case 'N': case 'O':
+ case 'P': case 'Q': case 'R': case 'S': case 'T':
+ case 'U': case 'V': case 'W': case 'X': case 'Y':
+ case 'Z':
+ case '[': case '\\': case ']': case '^': case '_':
+ case 'a': case 'b': case 'c': case 'd': case 'e':
+ case 'f': case 'g': case 'h': case 'i': case 'j':
+ case 'k': case 'l': case 'm': case 'n': case 'o':
+ case 'p': case 'q': case 'r': case 's': case 't':
+ case 'u': case 'v': case 'w': case 'x': case 'y':
+ case 'z': case '{': case '|': case '}': case '~':
+ /* c is in the ISO C "basic character set". */
+ is = isxdigit_l ((unsigned char) c, locale);
+ switch (c)
+ {
+ case '0': case '1': case '2': case '3': case '4':
+ case '5': case '6': case '7': case '8': case '9':
+ case 'A': case 'B': case 'C': case 'D': case 'E': case 'F':
+ case 'a': case 'b': case 'c': case 'd': case 'e': case 'f':
+ ASSERT (is != 0);
+ break;
+ default:
+ ASSERT (is == 0);
+ break;
+ }
+ break;
+ }
}
int
static void
test_function (void)
{
- int exp;
-
/* [MX] shaded specification in POSIX. */
/* NaN. */
- for (exp = -100000; exp <= 100000; exp += 100000)
+ for (int exp = -100000; exp <= 100000; exp += 100000)
ASSERT (ISNAN (LDEXP (NAN, exp)));
/* Signed zero. */
- for (exp = -100000; exp <= 100000; exp += 100000)
+ for (int exp = -100000; exp <= 100000; exp += 100000)
{
DOUBLE z = LDEXP (L_(0.0), exp);
ASSERT (z == L_(0.0));
ASSERT (!signbit (z));
}
- for (exp = -100000; exp <= 100000; exp += 100000)
+ for (int exp = -100000; exp <= 100000; exp += 100000)
{
DOUBLE z = LDEXP (MINUS_ZERO, exp);
ASSERT (z == L_(0.0));
}
/* Infinity. */
- for (exp = -100000; exp <= 100000; exp += 100000)
+ for (int exp = -100000; exp <= 100000; exp += 100000)
ASSERT (LDEXP (INFINITY, exp) == INFINITY);
- for (exp = -100000; exp <= 100000; exp += 100000)
+ for (int exp = -100000; exp <= 100000; exp += 100000)
ASSERT (LDEXP (- INFINITY, exp) == - INFINITY);
}
static void
test_function (void)
{
- int i;
volatile DOUBLE x;
volatile DOUBLE y;
y = LDEXP (x, -5); ASSERT (y == x * L_(0.03125));
}
- for (i = 1, x = L_(1.73205); i <= MAX_EXP; i++, x *= L_(2.0))
- {
- y = LDEXP (x, 0); ASSERT (y == x);
+ {
+ int i;
+
+ for (i = 1, x = L_(1.73205); i <= MAX_EXP; i++, x *= L_(2.0))
{
- volatile DOUBLE expected;
- y = LDEXP (x, 5);
- expected = x * L_(32.0);
- ASSERT (y == expected);
- }
- y = LDEXP (x, -5); ASSERT (y == x * 0.03125L);
- y = LDEXP (x, INT_MIN); ASSERT (y == 0);
- }
- for (i = 1, x = L_(1.73205); i >= MIN_EXP; i--, x *= L_(0.5))
- {
- y = LDEXP (x, 0); ASSERT (y == x);
- y = LDEXP (x, 5); ASSERT (y == x * L_(32.0));
- if (i - 5 >= MIN_EXP)
+ y = LDEXP (x, 0); ASSERT (y == x);
{
- y = LDEXP (x, -5); ASSERT (y == x * L_(0.03125));
+ volatile DOUBLE expected;
+ y = LDEXP (x, 5);
+ expected = x * L_(32.0);
+ ASSERT (y == expected);
}
- }
- for (; i >= LDBL_MIN_EXP - 100 && x > L_(0.0); i--, x *= L_(0.5))
- {
- y = LDEXP (x, 0); ASSERT (y == x);
- y = LDEXP (x, 5); ASSERT (y == x * L_(32.0));
- }
+ y = LDEXP (x, -5); ASSERT (y == x * 0.03125L);
+ y = LDEXP (x, INT_MIN); ASSERT (y == 0);
+ }
+ for (i = 1, x = L_(1.73205); i >= MIN_EXP; i--, x *= L_(0.5))
+ {
+ y = LDEXP (x, 0); ASSERT (y == x);
+ y = LDEXP (x, 5); ASSERT (y == x * L_(32.0));
+ if (i - 5 >= MIN_EXP)
+ {
+ y = LDEXP (x, -5); ASSERT (y == x * L_(0.03125));
+ }
+ }
+ for (; i >= LDBL_MIN_EXP - 100 && x > L_(0.0); i--, x *= L_(0.5))
+ {
+ y = LDEXP (x, 0); ASSERT (y == x);
+ y = LDEXP (x, 5); ASSERT (y == x * L_(32.0));
+ }
+ }
/* Randomized tests. */
- for (i = 0; i < SIZEOF (RANDOM); i++)
+ for (int i = 0; i < SIZEOF (RANDOM); i++)
{
- int u, v;
-
x = L_(20.0) * RANDOM[i] - L_(10.0); /* -10.0 <= x <= 10.0 */
/* LDEXP only does rounding when it returns a denormalized number
or there is underflow. It doesn't happen here. */
- for (u = -10; u <= 10; u++)
- for (v = -10; v <= 10; v++)
+ for (int u = -10; u <= 10; u++)
+ for (int v = -10; v <= 10; v++)
ASSERT (LDEXP (x, u + v) == LDEXP (LDEXP (x, u), v));
}
}
main (int argc, char *argv[])
{
const char *program_name = argv[0];
- int i;
/* Parse the command-line arguments. */
- for (i = 1; i < argc; i++)
+ for (int i = 1; i < argc; i++)
{
const char *arg = argv[i];
if (str_startswith (arg, "--color="))
int
main (void)
{
- int i;
int dfd;
char *cwd;
int result;
last scenario (two relative paths given, neither one AT_FDCWD)
has two paths, based on whether the two fds are equivalent, so we
do the other variant after the loop. */
- for (i = 0; i < 32; i++)
+ for (int i = 0; i < 32; i++)
{
int fd1 = (i & 8) ? dfd : AT_FDCWD;
char *file1 = mfile_name_concat ((i & 4) ? ".." : cwd, BASE "xx", NULL);
static void
check_equals (gl_list_t list1, gl_list_t list2)
{
- size_t n, i;
+ size_t n;
n = gl_list_size (list1);
ASSERT (n == gl_list_size (list2));
- for (i = 0; i < n; i++)
+ for (size_t i = 0; i < n; i++)
{
ASSERT (gl_list_get_at (list1, i) == gl_list_get_at (list2, i));
}
size_t initial_size = RANDOM (50);
const void **contents =
(const void **) malloc (initial_size * sizeof (const void *));
- size_t i;
- unsigned int repeat;
- for (i = 0; i < initial_size; i++)
+ for (size_t i = 0; i < initial_size; i++)
contents[i] = RANDOM_OBJECT ();
/* Create list1. */
/* Create list2. */
list2 = gl_list_nx_create_empty (GL_LINKED_LIST, NULL, NULL, NULL, true);
ASSERT (list2 != NULL);
- for (i = 0; i < initial_size; i++)
+ for (size_t i = 0; i < initial_size; i++)
ASSERT (gl_list_nx_add_last (list2, contents[i]) != NULL);
/* Create list3. */
check_equals_by_forward_iteration (list1, list2);
check_equals_by_backward_iteration (list1, list2);
- for (repeat = 0; repeat < 10000; repeat++)
+ for (unsigned int repeat = 0; repeat < 10000; repeat++)
{
unsigned int operation = RANDOM (18);
switch (operation)
iter1 = gl_list_iterator (list1);
iter2 = gl_list_iterator (list2);
iter3 = gl_list_iterator (list3);
- for (i = 0; i < n; i++)
+ for (size_t i = 0; i < n; i++)
{
ASSERT (gl_list_iterator_next (&iter1, &elt, NULL));
ASSERT (gl_list_get_at (list1, i) == elt);
iter1 = gl_list_iterator_from_to (list1, start, end);
iter2 = gl_list_iterator_from_to (list2, start, end);
iter3 = gl_list_iterator_from_to (list3, start, end);
- for (i = start; i < end; i++)
+ for (size_t i = start; i < end; i++)
{
ASSERT (gl_list_iterator_next (&iter1, &elt, NULL));
ASSERT (gl_list_get_at (list1, i) == elt);
static void
check_equals (gl_list_t list1, gl_list_t list2)
{
- size_t n, i;
+ size_t n;
n = gl_list_size (list1);
ASSERT (n == gl_list_size (list2));
- for (i = 0; i < n; i++)
+ for (size_t i = 0; i < n; i++)
{
ASSERT (gl_list_get_at (list1, i) == gl_list_get_at (list2, i));
}
size_t initial_size = RANDOM (50);
const void **contents =
(const void **) malloc (initial_size * sizeof (const void *));
- size_t i;
- unsigned int repeat;
- for (i = 0; i < initial_size; i++)
+ for (size_t i = 0; i < initial_size; i++)
contents[i] = RANDOM_OBJECT ();
/* Create list1. */
list2 = gl_list_nx_create_empty (GL_LINKEDHASH_LIST,
string_equals, string_hash, NULL, true);
ASSERT (list2 != NULL);
- for (i = 0; i < initial_size; i++)
+ for (size_t i = 0; i < initial_size; i++)
ASSERT (gl_list_nx_add_last (list2, contents[i]) != NULL);
/* Create list3. */
check_equals_by_forward_iteration (list1, list2);
check_equals_by_backward_iteration (list1, list2);
- for (repeat = 0; repeat < 10000; repeat++)
+ for (unsigned int repeat = 0; repeat < 10000; repeat++)
{
unsigned int operation = RANDOM (18);
switch (operation)
iter1 = gl_list_iterator (list1);
iter2 = gl_list_iterator (list2);
iter3 = gl_list_iterator (list3);
- for (i = 0; i < n; i++)
+ for (size_t i = 0; i < n; i++)
{
ASSERT (gl_list_iterator_next (&iter1, &elt, NULL));
ASSERT (gl_list_get_at (list1, i) == elt);
iter1 = gl_list_iterator_from_to (list1, start, end);
iter2 = gl_list_iterator_from_to (list2, start, end);
iter3 = gl_list_iterator_from_to (list3, start, end);
- for (i = start; i < end; i++)
+ for (size_t i = start; i < end; i++)
{
ASSERT (gl_list_iterator_next (&iter1, &elt, NULL));
ASSERT (gl_list_get_at (list1, i) == elt);
const void *value1;
const void *key2;
const void *value2;
- size_t i;
iter1 = gl_map_iterator (map1);
iter2 = gl_map_iterator (map2);
- for (i = 0; i < n; i++)
+ for (size_t i = 0; i < n; i++)
{
ASSERT (gl_map_iterator_next (&iter1, &key1, &value1));
ASSERT (gl_map_iterator_next (&iter2, &key2, &value2));
qsort (pairs_of_map1, n, sizeof (struct pair), cmp_pairs_in_array);
qsort (pairs_of_map2, n, sizeof (struct pair), cmp_pairs_in_array);
}
- for (i = 0; i < n; i++)
+ for (size_t i = 0; i < n; i++)
{
ASSERT (pairs_of_map1[i].key == pairs_of_map2[i].key);
ASSERT (pairs_of_map1[i].value == pairs_of_map2[i].value);
{
size_t initial_size = RANDOM (20);
- size_t i;
- unsigned int repeat;
/* Create map1. */
map1 = gl_map_nx_create_empty (GL_ARRAY_MAP,
check_all (map1, map2);
/* Initialize them. */
- for (i = 0; i < initial_size; i++)
+ for (size_t i = 0; i < initial_size; i++)
{
const char *key = RANDOM_OBJECT ();
const char *value = RANDOM_OBJECT ();
check_all (map1, map2);
}
- for (repeat = 0; repeat < 100000; repeat++)
+ for (unsigned int repeat = 0; repeat < 100000; repeat++)
{
unsigned int operation = RANDOM (3);
switch (operation)
gl_set_iterator_t iter2;
const void *elt1;
const void *elt2;
- size_t i;
iter1 = gl_set_iterator (set1);
iter2 = gl_set_iterator (set2);
- for (i = 0; i < n; i++)
+ for (size_t i = 0; i < n; i++)
{
ASSERT (gl_set_iterator_next (&iter1, &elt1));
ASSERT (gl_set_iterator_next (&iter2, &elt2));
qsort (elements_of_set1, n, sizeof (const void *), cmp_objects_in_array);
qsort (elements_of_set2, n, sizeof (const void *), cmp_objects_in_array);
}
- for (i = 0; i < n; i++)
+ for (size_t i = 0; i < n; i++)
ASSERT (elements_of_set1[i] == elements_of_set2[i]);
free (elements_of_set2);
free (elements_of_set1);
string_hashcode (const void *elt)
{
size_t hashcode = 0;
- const char *s;
- for (s = (const char *) elt; *s != '\0'; s++)
+ for (const char *s = (const char *) elt; *s != '\0'; s++)
hashcode += (unsigned char) *s;
return hashcode;
}
{
size_t initial_size = RANDOM (20);
- size_t i;
- unsigned int repeat;
/* Create set1. */
set1 = gl_set_nx_create_empty (GL_ARRAY_SET, string_equals, string_hashcode, NULL);
check_all (set1, set2);
/* Initialize them. */
- for (i = 0; i < initial_size; i++)
+ for (size_t i = 0; i < initial_size; i++)
{
const char *obj = RANDOM_OBJECT ();
ASSERT (gl_set_nx_add (set1, obj) == gl_set_nx_add (set2, obj));
check_all (set1, set2);
}
- for (repeat = 0; repeat < 100000; repeat++)
+ for (unsigned int repeat = 0; repeat < 100000; repeat++)
{
unsigned int operation = RANDOM (3);
switch (operation)
/* Check that gl_locale_name distinguishes different categories of the
thread locale, and that the name is the right one for each. */
- {
- unsigned int i;
-
- for (i = 0; i < SIZEOF (categories); i++)
- {
- int category_mask = categories[i].mask;
- locale_t loc = newlocale (LC_ALL_MASK, "fr_FR.UTF-8", NULL);
- if (loc != NULL)
- {
- locale_t locale = newlocale (category_mask, "de_DE.UTF-8", loc);
- if (locale == NULL)
- freelocale (loc);
- else
- {
- unsigned int j;
-
- uselocale (locale);
- for (j = 0; j < SIZEOF (categories); j++)
- {
- const char *name_j =
- gl_locale_name (categories[j].cat, categories[j].string);
- if (j == i)
- ASSERT (strcmp (name_j, "de_DE.UTF-8") == 0);
- else
- ASSERT (strcmp (name_j, "fr_FR.UTF-8") == 0);
- }
- uselocale (LC_GLOBAL_LOCALE);
- freelocale (locale);
- }
- }
- }
- }
+ for (unsigned int i = 0; i < SIZEOF (categories); i++)
+ {
+ int category_mask = categories[i].mask;
+ locale_t loc = newlocale (LC_ALL_MASK, "fr_FR.UTF-8", NULL);
+ if (loc != NULL)
+ {
+ locale_t locale = newlocale (category_mask, "de_DE.UTF-8", loc);
+ if (locale == NULL)
+ freelocale (loc);
+ else
+ {
+ uselocale (locale);
+ for (unsigned int j = 0; j < SIZEOF (categories); j++)
+ {
+ const char *name_j =
+ gl_locale_name (categories[j].cat, categories[j].string);
+ if (j == i)
+ ASSERT (strcmp (name_j, "de_DE.UTF-8") == 0);
+ else
+ ASSERT (strcmp (name_j, "fr_FR.UTF-8") == 0);
+ }
+ uselocale (LC_GLOBAL_LOCALE);
+ freelocale (locale);
+ }
+ }
+ }
#endif
}
/* Check that gl_locale_name_thread distinguishes different categories of the
thread locale, and that the name is the right one for each. */
- {
- unsigned int i;
-
- for (i = 0; i < SIZEOF (categories); i++)
- {
- int category_mask = categories[i].mask;
- locale_t loc = newlocale (LC_ALL_MASK, "fr_FR.UTF-8", NULL);
- if (loc != NULL)
- {
- locale_t locale = newlocale (category_mask, "de_DE.UTF-8", loc);
- if (locale == NULL)
- freelocale (loc);
- else
- {
- unsigned int j;
-
- uselocale (locale);
- for (j = 0; j < SIZEOF (categories); j++)
- {
- const char *name_j =
- gl_locale_name_thread (categories[j].cat,
- categories[j].string);
- if (j == i)
- ASSERT (strcmp (name_j, "de_DE.UTF-8") == 0);
- else
- ASSERT (strcmp (name_j, "fr_FR.UTF-8") == 0);
- }
- uselocale (LC_GLOBAL_LOCALE);
- freelocale (locale);
- }
- }
- }
- }
+ for (unsigned int i = 0; i < SIZEOF (categories); i++)
+ {
+ int category_mask = categories[i].mask;
+ locale_t loc = newlocale (LC_ALL_MASK, "fr_FR.UTF-8", NULL);
+ if (loc != NULL)
+ {
+ locale_t locale = newlocale (category_mask, "de_DE.UTF-8", loc);
+ if (locale == NULL)
+ freelocale (loc);
+ else
+ {
+ uselocale (locale);
+ for (unsigned int j = 0; j < SIZEOF (categories); j++)
+ {
+ const char *name_j =
+ gl_locale_name_thread (categories[j].cat,
+ categories[j].string);
+ if (j == i)
+ ASSERT (strcmp (name_j, "de_DE.UTF-8") == 0);
+ else
+ ASSERT (strcmp (name_j, "fr_FR.UTF-8") == 0);
+ }
+ uselocale (LC_GLOBAL_LOCALE);
+ freelocale (locale);
+ }
+ }
+ }
/* Check that gl_locale_name_thread returns a string that is allocated with
indefinite extent. */
/* Array of remembered results of gl_locale_name_thread, stored in safe
memory. */
char *saved_names[SIZEOF (choices)][SIZEOF (categories)];
- unsigned int j;
- for (j = 0; j < SIZEOF (choices); j++)
+ for (unsigned int j = 0; j < SIZEOF (choices); j++)
{
locale_t locale = newlocale (LC_ALL_MASK, choices[j], NULL);
available[j] = (locale != NULL);
if (locale != NULL)
{
- unsigned int i;
-
uselocale (locale);
- for (i = 0; i < SIZEOF (categories); i++)
+ for (unsigned int i = 0; i < SIZEOF (categories); i++)
{
unsaved_names[j][i] = gl_locale_name_thread (categories[i].cat, categories[i].string);
saved_names[j][i] = strdup (unsaved_names[j][i]);
}
}
/* Verify the unsaved_names are still valid. */
- for (j = 0; j < SIZEOF (choices); j++)
+ for (unsigned int j = 0; j < SIZEOF (choices); j++)
if (available[j])
{
- unsigned int i;
-
- for (i = 0; i < SIZEOF (categories); i++)
+ for (unsigned int i = 0; i < SIZEOF (categories); i++)
ASSERT (strcmp (unsaved_names[j][i], saved_names[j][i]) == 0);
}
/* Allocate many locales, without freeing them. This is an attempt at
overwriting as much of the previously allocated memory as possible. */
- for (j = SIZEOF (choices); j > 0; )
+ for (unsigned int j = SIZEOF (choices); j > 0; )
{
j--;
if (available[j])
{
locale_t locale = newlocale (LC_ALL_MASK, choices[j], NULL);
- unsigned int i;
ASSERT (locale != NULL);
uselocale (locale);
- for (i = 0; i < SIZEOF (categories); i++)
+ for (unsigned int i = 0; i < SIZEOF (categories); i++)
{
const char *name = gl_locale_name_thread (categories[i].cat, categories[i].string);
ASSERT (strcmp (unsaved_names[j][i], name) == 0);
}
}
/* Verify the unsaved_names are still valid. */
- for (j = 0; j < SIZEOF (choices); j++)
+ for (unsigned int j = 0; j < SIZEOF (choices); j++)
if (available[j])
{
- unsigned int i;
-
- for (i = 0; i < SIZEOF (categories); i++)
+ for (unsigned int i = 0; i < SIZEOF (categories); i++)
{
ASSERT (strcmp (unsaved_names[j][i], saved_names[j][i]) == 0);
free (saved_names[j][i]);
static void
check_accounts (void)
{
- int i, sum;
+ int sum;
sum = 0;
- for (i = 0; i < ACCOUNT_COUNT; i++)
+ for (int i = 0; i < ACCOUNT_COUNT; i++)
sum += account[i];
if (sum != ACCOUNT_COUNT * 1000)
abort ();
static void *
lock_mutator_thread (_GL_UNUSED void *arg)
{
- int repeat;
-
- for (repeat = REPEAT_COUNT; repeat > 0; repeat--)
+ for (int repeat = REPEAT_COUNT; repeat > 0; repeat--)
{
int i1, i2, value;
static void
test_lock (void)
{
- int i;
gl_thread_t checkerthread;
gl_thread_t threads[THREAD_COUNT];
/* Initialization. */
- for (i = 0; i < ACCOUNT_COUNT; i++)
+ for (int i = 0; i < ACCOUNT_COUNT; i++)
account[i] = 1000;
init_atomic_int (&lock_checker_done);
set_atomic_int_value (&lock_checker_done, 0);
/* Spawn the threads. */
checkerthread = gl_thread_create (lock_checker_thread, NULL);
- for (i = 0; i < THREAD_COUNT; i++)
+ for (int i = 0; i < THREAD_COUNT; i++)
threads[i] = gl_thread_create (lock_mutator_thread, NULL);
/* Wait for the threads to terminate. */
- for (i = 0; i < THREAD_COUNT; i++)
+ for (int i = 0; i < THREAD_COUNT; i++)
gl_thread_join (threads[i], NULL);
set_atomic_int_value (&lock_checker_done, 1);
gl_thread_join (checkerthread, NULL);
static void *
rwlock_mutator_thread (_GL_UNUSED void *arg)
{
- int repeat;
-
- for (repeat = REPEAT_COUNT; repeat > 0; repeat--)
+ for (int repeat = REPEAT_COUNT; repeat > 0; repeat--)
{
int i1, i2, value;
static void
test_rwlock (void)
{
- int i;
gl_thread_t checkerthreads[THREAD_COUNT];
gl_thread_t threads[THREAD_COUNT];
/* Initialization. */
- for (i = 0; i < ACCOUNT_COUNT; i++)
+ for (int i = 0; i < ACCOUNT_COUNT; i++)
account[i] = 1000;
init_atomic_int (&rwlock_checker_done);
set_atomic_int_value (&rwlock_checker_done, 0);
/* Spawn the threads. */
- for (i = 0; i < THREAD_COUNT; i++)
+ for (int i = 0; i < THREAD_COUNT; i++)
checkerthreads[i] = gl_thread_create (rwlock_checker_thread, NULL);
- for (i = 0; i < THREAD_COUNT; i++)
+ for (int i = 0; i < THREAD_COUNT; i++)
threads[i] = gl_thread_create (rwlock_mutator_thread, NULL);
/* Wait for the threads to terminate. */
- for (i = 0; i < THREAD_COUNT; i++)
+ for (int i = 0; i < THREAD_COUNT; i++)
gl_thread_join (threads[i], NULL);
set_atomic_int_value (&rwlock_checker_done, 1);
- for (i = 0; i < THREAD_COUNT; i++)
+ for (int i = 0; i < THREAD_COUNT; i++)
gl_thread_join (checkerthreads[i], NULL);
check_accounts ();
}
static void *
reclock_mutator_thread (_GL_UNUSED void *arg)
{
- int repeat;
-
- for (repeat = REPEAT_COUNT; repeat > 0; repeat--)
+ for (int repeat = REPEAT_COUNT; repeat > 0; repeat--)
{
recshuffle ();
static void
test_recursive_lock (void)
{
- int i;
gl_thread_t checkerthread;
gl_thread_t threads[THREAD_COUNT];
/* Initialization. */
- for (i = 0; i < ACCOUNT_COUNT; i++)
+ for (int i = 0; i < ACCOUNT_COUNT; i++)
account[i] = 1000;
init_atomic_int (&reclock_checker_done);
set_atomic_int_value (&reclock_checker_done, 0);
/* Spawn the threads. */
checkerthread = gl_thread_create (reclock_checker_thread, NULL);
- for (i = 0; i < THREAD_COUNT; i++)
+ for (int i = 0; i < THREAD_COUNT; i++)
threads[i] = gl_thread_create (reclock_mutator_thread, NULL);
/* Wait for the threads to terminate. */
- for (i = 0; i < THREAD_COUNT; i++)
+ for (int i = 0; i < THREAD_COUNT; i++)
gl_thread_join (threads[i], NULL);
set_atomic_int_value (&reclock_checker_done, 1);
gl_thread_join (checkerthread, NULL);
once_contender_thread (void *arg)
{
int id = (int) (intptr_t) arg;
- int repeat;
- for (repeat = 0; repeat <= REPEAT_COUNT; repeat++)
+ for (int repeat = 0; repeat <= REPEAT_COUNT; repeat++)
{
/* Tell the main thread that we're ready. */
gl_lock_lock (ready_lock[id]);
static void
test_once (void)
{
- int i, repeat;
gl_thread_t threads[THREAD_COUNT];
/* Initialize all variables. */
- for (i = 0; i < THREAD_COUNT; i++)
+ for (int i = 0; i < THREAD_COUNT; i++)
{
ready[i] = 0;
gl_lock_init (ready_lock[i]);
}
#if ENABLE_LOCKING
- for (i = 0; i < REPEAT_COUNT; i++)
+ for (int i = 0; i < REPEAT_COUNT; i++)
gl_rwlock_init (fire_signal[i]);
#else
fire_signal_state = 0;
#if ENABLE_LOCKING
/* Block all fire_signals. */
- for (i = REPEAT_COUNT-1; i >= 0; i--)
+ for (int i = REPEAT_COUNT-1; i >= 0; i--)
gl_rwlock_wrlock (fire_signal[i]);
#endif
/* Spawn the threads. */
- for (i = 0; i < THREAD_COUNT; i++)
+ for (int i = 0; i < THREAD_COUNT; i++)
threads[i] =
gl_thread_create (once_contender_thread, (void *) (intptr_t) i);
- for (repeat = 0; repeat <= REPEAT_COUNT; repeat++)
+ for (int repeat = 0; repeat <= REPEAT_COUNT; repeat++)
{
/* Wait until every thread is ready. */
dbgprintf ("Main thread before synchronizing for round %d\n", repeat);
for (;;)
{
int ready_count = 0;
- for (i = 0; i < THREAD_COUNT; i++)
+ for (int i = 0; i < THREAD_COUNT; i++)
{
gl_lock_lock (ready_lock[i]);
ready_count += ready[i];
performed = 0;
/* Preparation for the next round: Reset the ready flags. */
- for (i = 0; i < THREAD_COUNT; i++)
+ for (int i = 0; i < THREAD_COUNT; i++)
{
gl_lock_lock (ready_lock[i]);
ready[i] = 0;
}
/* Wait for the threads to terminate. */
- for (i = 0; i < THREAD_COUNT; i++)
+ for (int i = 0; i < THREAD_COUNT; i++)
gl_thread_join (threads[i], NULL);
}
static void
test_function (void)
{
- int i;
- int j;
const DOUBLE TWO_MANT_DIG =
/* Assume MANT_DIG <= 5 * 31.
Use the identity
#endif
);
- for (i = 0; i < SIZEOF (RANDOM); i++)
+ for (int i = 0; i < SIZEOF (RANDOM); i++)
{
DOUBLE x = L_(16.0) * RANDOM[i] + L_(1.0); /* 1.0 <= x <= 17.0 */
DOUBLE y = LOG (x);
#endif
: L_(7.0));
- for (i = 0; i < SIZEOF (RANDOM) / 5; i++)
- for (j = 0; j < SIZEOF (RANDOM) / 5; j++)
+ for (int i = 0; i < SIZEOF (RANDOM) / 5; i++)
+ for (int j = 0; j < SIZEOF (RANDOM) / 5; j++)
{
DOUBLE x = L_(17.0) / (L_(16.0) - L_(15.0) * RANDOM[i]) - L_(1.0);
DOUBLE y = L_(17.0) / (L_(16.0) - L_(15.0) * RANDOM[j]) - L_(1.0);
static void
test_function (void)
{
- int i;
- int j;
const DOUBLE TWO_MANT_DIG =
/* Assume MANT_DIG <= 5 * 31.
Use the identity
#endif
: L_(3.0));
- for (i = 0; i < SIZEOF (RANDOM); i++)
+ for (int i = 0; i < SIZEOF (RANDOM); i++)
{
DOUBLE x = L_(16.0) * RANDOM[i] + L_(1.0); /* 1.0 <= x <= 17.0 */
DOUBLE y = LOG10 (x);
#endif
: L_(5.0));
- for (i = 0; i < SIZEOF (RANDOM) / 5; i++)
- for (j = 0; j < SIZEOF (RANDOM) / 5; j++)
+ for (int i = 0; i < SIZEOF (RANDOM) / 5; i++)
+ for (int j = 0; j < SIZEOF (RANDOM) / 5; j++)
{
DOUBLE x = L_(17.0) / (L_(16.0) - L_(15.0) * RANDOM[i]) - L_(1.0);
DOUBLE y = L_(17.0) / (L_(16.0) - L_(15.0) * RANDOM[j]) - L_(1.0);
static void
test_function (void)
{
- int i;
- int j;
const DOUBLE TWO_MANT_DIG =
/* Assume MANT_DIG <= 5 * 31.
Use the identity
#endif
: L_(13.0));
- for (i = 0; i < SIZEOF (RANDOM); i++)
+ for (int i = 0; i < SIZEOF (RANDOM); i++)
{
DOUBLE x = L_(16.0) * RANDOM[i]; /* 0.0 <= x <= 16.0 */
DOUBLE y = LOG1P (x);
#endif
: L_(61.0));
- for (i = 0; i < SIZEOF (RANDOM) / 5; i++)
- for (j = 0; j < SIZEOF (RANDOM) / 5; j++)
+ for (int i = 0; i < SIZEOF (RANDOM) / 5; i++)
+ for (int j = 0; j < SIZEOF (RANDOM) / 5; j++)
{
DOUBLE x = L_(17.0) / (L_(16.0) - L_(15.0) * RANDOM[i]) - L_(2.0);
DOUBLE y = L_(17.0) / (L_(16.0) - L_(15.0) * RANDOM[j]) - L_(2.0);
static void
test_function (void)
{
- int i;
- int j;
const DOUBLE TWO_MANT_DIG =
/* Assume MANT_DIG <= 5 * 31.
Use the identity
#endif
: L_(5.0));
- for (i = 0; i < SIZEOF (RANDOM); i++)
+ for (int i = 0; i < SIZEOF (RANDOM); i++)
{
DOUBLE x = L_(16.0) * RANDOM[i] + L_(1.0); /* 1.0 <= x <= 17.0 */
DOUBLE y = LOG2 (x);
#endif
: L_(9.0));
- for (i = 0; i < SIZEOF (RANDOM) / 5; i++)
- for (j = 0; j < SIZEOF (RANDOM) / 5; j++)
+ for (int i = 0; i < SIZEOF (RANDOM) / 5; i++)
+ for (int j = 0; j < SIZEOF (RANDOM) / 5; j++)
{
DOUBLE x = L_(17.0) / (L_(16.0) - L_(15.0) * RANDOM[i]) - L_(1.0);
DOUBLE y = L_(17.0) / (L_(16.0) - L_(15.0) * RANDOM[j]) - L_(1.0);
static void
test_function (void)
{
- int i;
VOLATILE DOUBLE x;
DOUBLE y;
ASSERT (LOGB (MINUS_ZERO) == - HUGEVAL);
/* From here on, this test assumes FLT_RADIX == 2. */
-
- for (i = 1, x = L_(1.0); i <= MAX_EXP; i++, x *= L_(2.0))
- {
- y = LOGB (x);
- ASSERT (y == (DOUBLE)(i - 1));
- }
- for (i = 1, x = L_(1.0); i >= MIN_NORMAL_EXP; i--, x *= L_(0.5))
- {
- y = LOGB (x);
- ASSERT (y == (DOUBLE)(i - 1));
- }
- for (; i >= MIN_EXP - 100 && x > L_(0.0); i--, x *= L_(0.5))
- {
- y = LOGB (x);
- ASSERT (y == (DOUBLE)(i - 1));
- }
-
- for (i = 1, x = - L_(1.0); i <= MAX_EXP; i++, x *= L_(2.0))
- {
- y = LOGB (x);
- ASSERT (y == (DOUBLE)(i - 1));
- }
- for (i = 1, x = - L_(1.0); i >= MIN_NORMAL_EXP; i--, x *= L_(0.5))
- {
- y = LOGB (x);
- ASSERT (y == (DOUBLE)(i - 1));
- }
- for (; i >= MIN_EXP - 100 && x < L_(0.0); i--, x *= L_(0.5))
- {
- y = LOGB (x);
- ASSERT (y == (DOUBLE)(i - 1));
- }
-
- for (i = 1, x = L_(1.01); i <= MAX_EXP; i++, x *= L_(2.0))
- {
- y = LOGB (x);
- ASSERT (y == (DOUBLE)(i - 1));
- }
- for (i = 1, x = L_(1.01); i >= MIN_NORMAL_EXP; i--, x *= L_(0.5))
- {
- y = LOGB (x);
- ASSERT (y == (DOUBLE)(i - 1));
- }
- for (; i >= MIN_EXP - 100 && x > L_(0.0); i--, x *= L_(0.5))
- {
- y = LOGB (x);
- ASSERT (y == (DOUBLE)(i - 1));
- }
-
- for (i = 1, x = L_(1.73205); i <= MAX_EXP; i++, x *= L_(2.0))
- {
- y = LOGB (x);
- ASSERT (y == (DOUBLE)(i - 1));
- }
- for (i = 1, x = L_(1.73205); i >= MIN_NORMAL_EXP; i--, x *= L_(0.5))
- {
- y = LOGB (x);
- ASSERT (y == (DOUBLE)(i - 1));
- }
- for (; i >= MIN_EXP - 100 && x > L_(0.0); i--, x *= L_(0.5))
- {
- y = LOGB (x);
- ASSERT (y == (DOUBLE)(i - 1) || y == (DOUBLE)i);
- }
+ {
+ int i;
+
+ for (i = 1, x = L_(1.0); i <= MAX_EXP; i++, x *= L_(2.0))
+ {
+ y = LOGB (x);
+ ASSERT (y == (DOUBLE)(i - 1));
+ }
+ for (i = 1, x = L_(1.0); i >= MIN_NORMAL_EXP; i--, x *= L_(0.5))
+ {
+ y = LOGB (x);
+ ASSERT (y == (DOUBLE)(i - 1));
+ }
+ for (; i >= MIN_EXP - 100 && x > L_(0.0); i--, x *= L_(0.5))
+ {
+ y = LOGB (x);
+ ASSERT (y == (DOUBLE)(i - 1));
+ }
+
+ for (i = 1, x = - L_(1.0); i <= MAX_EXP; i++, x *= L_(2.0))
+ {
+ y = LOGB (x);
+ ASSERT (y == (DOUBLE)(i - 1));
+ }
+ for (i = 1, x = - L_(1.0); i >= MIN_NORMAL_EXP; i--, x *= L_(0.5))
+ {
+ y = LOGB (x);
+ ASSERT (y == (DOUBLE)(i - 1));
+ }
+ for (; i >= MIN_EXP - 100 && x < L_(0.0); i--, x *= L_(0.5))
+ {
+ y = LOGB (x);
+ ASSERT (y == (DOUBLE)(i - 1));
+ }
+
+ for (i = 1, x = L_(1.01); i <= MAX_EXP; i++, x *= L_(2.0))
+ {
+ y = LOGB (x);
+ ASSERT (y == (DOUBLE)(i - 1));
+ }
+ for (i = 1, x = L_(1.01); i >= MIN_NORMAL_EXP; i--, x *= L_(0.5))
+ {
+ y = LOGB (x);
+ ASSERT (y == (DOUBLE)(i - 1));
+ }
+ for (; i >= MIN_EXP - 100 && x > L_(0.0); i--, x *= L_(0.5))
+ {
+ y = LOGB (x);
+ ASSERT (y == (DOUBLE)(i - 1));
+ }
+
+ for (i = 1, x = L_(1.73205); i <= MAX_EXP; i++, x *= L_(2.0))
+ {
+ y = LOGB (x);
+ ASSERT (y == (DOUBLE)(i - 1));
+ }
+ for (i = 1, x = L_(1.73205); i >= MIN_NORMAL_EXP; i--, x *= L_(0.5))
+ {
+ y = LOGB (x);
+ ASSERT (y == (DOUBLE)(i - 1));
+ }
+ for (; i >= MIN_EXP - 100 && x > L_(0.0); i--, x *= L_(0.5))
+ {
+ y = LOGB (x);
+ ASSERT (y == (DOUBLE)(i - 1) || y == (DOUBLE)i);
+ }
+ }
/* Randomized tests. */
- for (i = 0; i < SIZEOF (RANDOM); i++)
+ for (int i = 0; i < SIZEOF (RANDOM); i++)
{
x = L_(20.0) * RANDOM[i] - L_(10.0); /* -10.0 <= x <= 10.0 */
if (x != L_(0.0))
/* Check that fd = 0, 1, 2 are now open to the controlling terminal for the
current process and that it is a session of its own. */
- {
- int fd;
- for (fd = 0; fd < 3; fd++)
- if (!(tcgetpgrp (fd) == getpid ()))
- {
- ignore_value (freopen ("err", "w+", stderr));
- fprintf (stderr, "tcgetpgrp(%d) = %ld whereas getpid() = %ld\n",
- fd, (long) tcgetpgrp (fd), (long) getpid ());
- fflush (stderr);
- abort ();
- }
- for (fd = 0; fd < 3; fd++)
+ for (int fd = 0; fd < 3; fd++)
+ if (!(tcgetpgrp (fd) == getpid ()))
{
- pid_t sid = tcgetsid (fd);
- if (sid == -1)
- {
- if (!(errno == ENOSYS))
- {
- ignore_value (freopen ("err", "w+", stderr));
- fprintf (stderr, "tcgetsid(%d) = -1 and errno = %d\n",
- fd, errno);
- fflush (stderr);
- abort ();
- }
- }
- else
- {
- if (!(sid == getpid ()))
- {
- ignore_value (freopen ("err", "w+", stderr));
- fprintf (stderr, "tcgetsid(%d) = %ld whereas getpid() = %ld\n",
- fd, (long) tcgetsid (fd), (long) getpid ());
- fflush (stderr);
- abort ();
- }
- }
+ ignore_value (freopen ("err", "w+", stderr));
+ fprintf (stderr, "tcgetpgrp(%d) = %ld whereas getpid() = %ld\n",
+ fd, (long) tcgetpgrp (fd), (long) getpid ());
+ fflush (stderr);
+ abort ();
}
- }
+ for (int fd = 0; fd < 3; fd++)
+ {
+ pid_t sid = tcgetsid (fd);
+ if (sid == -1)
+ {
+ if (!(errno == ENOSYS))
+ {
+ ignore_value (freopen ("err", "w+", stderr));
+ fprintf (stderr, "tcgetsid(%d) = -1 and errno = %d\n",
+ fd, errno);
+ fflush (stderr);
+ abort ();
+ }
+ }
+ else
+ {
+ if (!(sid == getpid ()))
+ {
+ ignore_value (freopen ("err", "w+", stderr));
+ fprintf (stderr, "tcgetsid(%d) = %ld whereas getpid() = %ld\n",
+ fd, (long) tcgetsid (fd), (long) getpid ());
+ fflush (stderr);
+ abort ();
+ }
+ }
+ }
return 0;
}
int
main ()
{
- int i;
-
/* This slows down malloc a lot. */
unsetenv ("MALLOC_PERTURB_");
/* Repeat a lot of times, to make sure there's no memory leak. */
- for (i = 0; i < 50000; i++)
+ for (int i = 0; i < 50000; i++)
{
/* Try various values.
n = 0 gave a crash on Alpha with gcc-2.5.8.
/* Test single-byte input. */
{
- int c;
char buf[1];
memset (&state, '\0', sizeof (mbstate_t));
- for (c = 0; c < 0x100; c++)
+ for (int c = 0; c < 0x100; c++)
switch (c)
{
case '\t': case '\v': case '\f':
{
int codepage = atoi (argv[argc - 1]);
int result;
- int i;
result = 77;
- for (i = 1; i < argc - 1; i++)
+ for (int i = 1; i < argc - 1; i++)
{
int ret = test_one_locale (argv[i], codepage);
/* Test single-byte input. */
{
- int c;
char buf[1];
memset (&state, '\0', sizeof (mbstate_t));
- for (c = 0; c < 0x100; c++)
+ for (int c = 0; c < 0x100; c++)
switch (c)
{
case '\t': case '\v': case '\f':
case '1':
/* C or POSIX locale. */
{
- int c;
char buf[1];
memset (&state, '\0', sizeof (mbstate_t));
- for (c = 0; c < 0x100; c++)
+ for (int c = 0; c < 0x100; c++)
if (c != 0)
{
/* We are testing all nonnull bytes. */
/* Test single-byte input. */
{
- int c;
char buf[1];
memset (&state, '\0', sizeof (mbstate_t));
- for (c = 0; c < 0x100; c++)
+ for (int c = 0; c < 0x100; c++)
switch (c)
{
case '\t': case '\v': case '\f':
{
int codepage = atoi (argv[argc - 1]);
int result;
- int i;
result = 77;
- for (i = 1; i < argc - 1; i++)
+ for (int i = 1; i < argc - 1; i++)
{
int ret = test_one_locale (argv[i], codepage);
/* Test single-byte input. */
{
- int c;
char buf[1];
memset (&state, '\0', sizeof (mbstate_t));
- for (c = 0; c < 0x100; c++)
+ for (int c = 0; c < 0x100; c++)
switch (c)
{
case '\t': case '\v': case '\f':
case '1':
/* C or POSIX locale. */
{
- int c;
char buf[1];
memset (&state, '\0', sizeof (mbstate_t));
- for (c = 0; c < 0x100; c++)
+ for (int c = 0; c < 0x100; c++)
if (c != 0)
{
/* We are testing all nonnull bytes. */
/* Test single-byte input. */
{
- int c;
char buf[1];
memset (&state, '\0', sizeof (mbstate_t));
- for (c = 0; c < 0x100; c++)
+ for (int c = 0; c < 0x100; c++)
switch (c)
{
case '\t': case '\v': case '\f':
{
int codepage = atoi (argv[argc - 1]);
int result;
- int i;
result = 77;
- for (i = 1; i < argc - 1; i++)
+ for (int i = 1; i < argc - 1; i++)
{
int ret = test_one_locale (argv[i], codepage);
/* Test single-byte input. */
{
- int c;
char buf[1];
memset (&state, '\0', sizeof (mbstate_t));
- for (c = 0; c < 0x100; c++)
+ for (int c = 0; c < 0x100; c++)
switch (c)
{
case '\t': case '\v': case '\f':
case '1':
/* C or POSIX locale. */
{
- int c;
char buf[1];
memset (&state, '\0', sizeof (mbstate_t));
- for (c = 0; c < 0x100; c++)
+ for (int c = 0; c < 0x100; c++)
if (c != 0)
{
/* We are testing all nonnull bytes. */
/* Test single-byte input. */
{
- int c;
char buf[1];
memset (&state, '\0', sizeof (mbstate_t));
- for (c = 0; c < 0x100; c++)
+ for (int c = 0; c < 0x100; c++)
switch (c)
{
case '\t': case '\v': case '\f':
{
int codepage = atoi (argv[argc - 1]);
int result;
- int i;
result = 77;
- for (i = 1; i < argc - 1; i++)
+ for (int i = 1; i < argc - 1; i++)
{
int ret = test_one_locale (argv[i], codepage);
/* Test single-byte input. */
{
- int c;
char buf[1];
memset (&state, '\0', sizeof (mbstate_t));
- for (c = 0; c < 0x100; c++)
+ for (int c = 0; c < 0x100; c++)
switch (c)
{
case '\t': case '\v': case '\f':
case '1':
/* C or POSIX locale. */
{
- int c;
char buf[1];
memset (&state, '\0', sizeof (mbstate_t));
- for (c = 0; c < 0x100; c++)
+ for (int c = 0; c < 0x100; c++)
if (c != 0)
{
/* We are testing all nonnull bytes. */
if (argc > 1)
{
- int unlimited;
-
- for (unlimited = 0; unlimited < 2; unlimited++)
+ for (int unlimited = 0; unlimited < 2; unlimited++)
{
#define BUFSIZE 10
char32_t buf[BUFSIZE];
const char *src;
mbstate_t temp_state;
- {
- size_t i;
- for (i = 0; i < BUFSIZE; i++)
- buf[i] = (char32_t) 0xBADFACE;
- }
+ for (size_t i = 0; i < BUFSIZE; i++)
+ buf[i] = (char32_t) 0xBADFACE;
switch (argv[1][0])
{
ASSERT (mbsinit (&state));
}
{
- int c;
char input[2];
memset (&state, '\0', sizeof (mbstate_t));
- for (c = 0; c < 0x100; c++)
+ for (int c = 0; c < 0x100; c++)
if (c != 0)
{
/* We are testing all nonnull bytes. */
if (argc > 1)
{
- int unlimited;
-
- for (unlimited = 0; unlimited < 2; unlimited++)
+ for (int unlimited = 0; unlimited < 2; unlimited++)
{
#define BUFSIZE 10
wchar_t buf[BUFSIZE];
const char *src;
mbstate_t temp_state;
- {
- size_t i;
- for (i = 0; i < BUFSIZE; i++)
- buf[i] = (wchar_t) 0xBADFACE;
- }
+ for (size_t i = 0; i < BUFSIZE; i++)
+ buf[i] = (wchar_t) 0xBADFACE;
switch (argv[1][0])
{
ASSERT (mbsinit (&state));
}
{
- int c;
char input[2];
memset (&state, '\0', sizeof (mbstate_t));
- for (c = 0; c < 0x100; c++)
+ for (int c = 0; c < 0x100; c++)
if (c != 0)
{
/* We are testing all nonnull bytes. */
if (argc > 1)
{
- int unlimited;
-
- for (unlimited = 0; unlimited < 2; unlimited++)
+ for (int unlimited = 0; unlimited < 2; unlimited++)
{
#define BUFSIZE 10
char32_t buf[BUFSIZE];
const char *src;
mbstate_t temp_state;
- {
- size_t i;
- for (i = 0; i < BUFSIZE; i++)
- buf[i] = (char32_t) 0xBADFACE;
- }
+ for (size_t i = 0; i < BUFSIZE; i++)
+ buf[i] = (char32_t) 0xBADFACE;
switch (argv[1][0])
{
ASSERT (mbsinit (&state));
}
{
- int c;
char input[2];
memset (&state, '\0', sizeof (mbstate_t));
- for (c = 0; c < 0x100; c++)
+ for (int c = 0; c < 0x100; c++)
if (c != 0)
{
/* We are testing all nonnull bytes. */
if (argc > 1)
{
- int unlimited;
-
- for (unlimited = 0; unlimited < 2; unlimited++)
+ for (int unlimited = 0; unlimited < 2; unlimited++)
{
#define BUFSIZE 10
wchar_t buf[BUFSIZE];
const char *src;
mbstate_t temp_state;
- {
- size_t i;
- for (i = 0; i < BUFSIZE; i++)
- buf[i] = (wchar_t) 0xBADFACE;
- }
+ for (size_t i = 0; i < BUFSIZE; i++)
+ buf[i] = (wchar_t) 0xBADFACE;
switch (argv[1][0])
{
ASSERT (mbsinit (&state));
}
{
- int c;
char input[2];
memset (&state, '\0', sizeof (mbstate_t));
- for (c = 0; c < 0x100; c++)
+ for (int c = 0; c < 0x100; c++)
if (c != 0)
{
/* We are testing all nonnull bytes. */
if (argc > 1)
{
- int unlimited;
-
- for (unlimited = 0; unlimited < 2; unlimited++)
+ for (int unlimited = 0; unlimited < 2; unlimited++)
{
#define BUFSIZE 10
char32_t buf[BUFSIZE];
const char *src;
- {
- size_t i;
- for (i = 0; i < BUFSIZE; i++)
- buf[i] = (char32_t) 0xBADFACE;
- }
+ for (size_t i = 0; i < BUFSIZE; i++)
+ buf[i] = (char32_t) 0xBADFACE;
switch (argv[1][0])
{
ASSERT (buf[1] == (char32_t) 0xBADFACE);
}
{
- int c;
char input[2];
- for (c = 0; c < 0x100; c++)
+ for (int c = 0; c < 0x100; c++)
if (c != 0)
{
/* We are testing all nonnull bytes. */
if (argc > 1)
{
- int unlimited;
-
- for (unlimited = 0; unlimited < 2; unlimited++)
+ for (int unlimited = 0; unlimited < 2; unlimited++)
{
#define BUFSIZE 10
wchar_t buf[BUFSIZE];
const char *src;
- {
- size_t i;
- for (i = 0; i < BUFSIZE; i++)
- buf[i] = (wchar_t) 0xBADFACE;
- }
+ for (size_t i = 0; i < BUFSIZE; i++)
+ buf[i] = (wchar_t) 0xBADFACE;
switch (argv[1][0])
{
ASSERT (buf[1] == (wchar_t) 0xBADFACE);
}
{
- int c;
char input[2];
- for (c = 0; c < 0x100; c++)
+ for (int c = 0; c < 0x100; c++)
if (c != 0)
{
/* We are testing all nonnull bytes. */
if (memcmp (md2_buffer (in1, strlen (in1), buf), out1, MD2_DIGEST_SIZE) !=
0)
{
- size_t i;
printf ("expected:\n");
- for (i = 0; i < MD2_DIGEST_SIZE; i++)
+ for (size_t i = 0; i < MD2_DIGEST_SIZE; i++)
printf ("%02x ", out1[i] & 0xFF);
printf ("\ncomputed:\n");
- for (i = 0; i < MD2_DIGEST_SIZE; i++)
+ for (size_t i = 0; i < MD2_DIGEST_SIZE; i++)
printf ("%02x ", buf[i] & 0xFF);
printf ("\n");
return 1;
if (memcmp (md2_buffer (in2, strlen (in2), buf), out2, MD2_DIGEST_SIZE) !=
0)
{
- size_t i;
printf ("expected:\n");
- for (i = 0; i < MD2_DIGEST_SIZE; i++)
+ for (size_t i = 0; i < MD2_DIGEST_SIZE; i++)
printf ("%02x ", out2[i] & 0xFF);
printf ("\ncomputed:\n");
- for (i = 0; i < MD2_DIGEST_SIZE; i++)
+ for (size_t i = 0; i < MD2_DIGEST_SIZE; i++)
printf ("%02x ", buf[i] & 0xFF);
printf ("\n");
return 1;
if (memcmp (md4_buffer (in1, strlen (in1), buf), out1, MD4_DIGEST_SIZE) !=
0)
{
- size_t i;
printf ("expected:\n");
- for (i = 0; i < MD4_DIGEST_SIZE; i++)
+ for (size_t i = 0; i < MD4_DIGEST_SIZE; i++)
printf ("%02x ", out1[i] & 0xFF);
printf ("\ncomputed:\n");
- for (i = 0; i < MD4_DIGEST_SIZE; i++)
+ for (size_t i = 0; i < MD4_DIGEST_SIZE; i++)
printf ("%02x ", buf[i] & 0xFF);
printf ("\n");
return 1;
if (memcmp (md4_buffer (in2, strlen (in2), buf), out2, MD4_DIGEST_SIZE) !=
0)
{
- size_t i;
printf ("expected:\n");
- for (i = 0; i < MD4_DIGEST_SIZE; i++)
+ for (size_t i = 0; i < MD4_DIGEST_SIZE; i++)
printf ("%02x ", out2[i] & 0xFF);
printf ("\ncomputed:\n");
- for (i = 0; i < MD4_DIGEST_SIZE; i++)
+ for (size_t i = 0; i < MD4_DIGEST_SIZE; i++)
printf ("%02x ", buf[i] & 0xFF);
printf ("\n");
return 1;
if (memcmp (md5_buffer (in1, strlen (in1), buf), out1, MD5_DIGEST_SIZE) != 0)
{
- size_t i;
printf ("expected:\n");
- for (i = 0; i < MD5_DIGEST_SIZE; i++)
+ for (size_t i = 0; i < MD5_DIGEST_SIZE; i++)
printf ("%02x ", out1[i] & 0xFFu);
printf ("\ncomputed:\n");
- for (i = 0; i < MD5_DIGEST_SIZE; i++)
+ for (size_t i = 0; i < MD5_DIGEST_SIZE; i++)
printf ("%02x ", buf[i] & 0xFFu);
printf ("\n");
return 1;
if (memcmp (md5_buffer (in2, strlen (in2), buf), out2, MD5_DIGEST_SIZE) != 0)
{
- size_t i;
printf ("expected:\n");
- for (i = 0; i < MD5_DIGEST_SIZE; i++)
+ for (size_t i = 0; i < MD5_DIGEST_SIZE; i++)
printf ("%02x ", out2[i] & 0xFFu);
printf ("\ncomputed:\n");
- for (i = 0; i < MD5_DIGEST_SIZE; i++)
+ for (size_t i = 0; i < MD5_DIGEST_SIZE; i++)
printf ("%02x ", buf[i] & 0xFFu);
printf ("\n");
return 1;
void *aligned16_blocks[SIZEOF (sizes)];
void *aligned32_blocks[SIZEOF (sizes)];
void *aligned64_blocks[SIZEOF (sizes)];
- size_t i;
- for (i = 0; i < SIZEOF (sizes); i++)
+ for (size_t i = 0; i < SIZEOF (sizes); i++)
{
size_t size = sizes[i];
memset (aligned64_blocks[i], 'z', size);
}
- for (i = 0; i < SIZEOF (sizes); i++)
+ for (size_t i = 0; i < SIZEOF (sizes); i++)
{
free (aligned2_blocks[i]);
free (aligned4_blocks[i]);
{
char foo[21];
char bar[21];
- int i;
- for (i = 0; i < 4; i++)
+ for (int i = 0; i < 4; i++)
{
char *a = foo + i;
char *b = bar + i;
int
main (void)
{
- size_t n = 0x100000;
- char *input = malloc (n);
- ASSERT (input);
-
- input[0] = 'a';
- input[1] = 'b';
- memset (input + 2, 'c', 1024);
- memset (input + 1026, 'd', n - 1028);
- input[n - 2] = 'e';
- input[n - 1] = 'a';
-
- /* Basic behavior tests. */
- ASSERT (memchr (input, 'a', n) == input);
-
- ASSERT (memchr (input, 'a', 0) == NULL);
-
{
- void *page_boundary = zerosize_ptr ();
- if (page_boundary)
- ASSERT (memchr (page_boundary, 'a', 0) == NULL);
- }
-
- ASSERT (memchr (input, 'b', n) == input + 1);
- ASSERT (memchr (input, 'c', n) == input + 2);
- ASSERT (memchr (input, 'd', n) == input + 1026);
-
- ASSERT (memchr (input + 1, 'a', n - 1) == input + n - 1);
- ASSERT (memchr (input + 1, 'e', n - 1) == input + n - 2);
- ASSERT (memchr (input + 1, 0x789abc00 | 'e', n - 1) == input + n - 2);
-
- ASSERT (memchr (input, 'f', n) == NULL);
- ASSERT (memchr (input, '\0', n) == NULL);
-
- /* Check that a very long haystack is handled quickly if the byte is
- found near the beginning. */
- {
- size_t repeat = 10000;
- for (; repeat > 0; repeat--)
- {
- ASSERT (memchr (input, 'c', n) == input + 2);
- }
- }
-
- /* Alignment tests. */
- {
- int i, j;
- for (i = 0; i < 32; i++)
+ size_t n = 0x100000;
+ char *input = malloc (n);
+ ASSERT (input);
+
+ input[0] = 'a';
+ input[1] = 'b';
+ memset (input + 2, 'c', 1024);
+ memset (input + 1026, 'd', n - 1028);
+ input[n - 2] = 'e';
+ input[n - 1] = 'a';
+
+ /* Basic behavior tests. */
+ ASSERT (memchr (input, 'a', n) == input);
+
+ ASSERT (memchr (input, 'a', 0) == NULL);
+
+ {
+ void *page_boundary = zerosize_ptr ();
+ if (page_boundary)
+ ASSERT (memchr (page_boundary, 'a', 0) == NULL);
+ }
+
+ ASSERT (memchr (input, 'b', n) == input + 1);
+ ASSERT (memchr (input, 'c', n) == input + 2);
+ ASSERT (memchr (input, 'd', n) == input + 1026);
+
+ ASSERT (memchr (input + 1, 'a', n - 1) == input + n - 1);
+ ASSERT (memchr (input + 1, 'e', n - 1) == input + n - 2);
+ ASSERT (memchr (input + 1, 0x789abc00 | 'e', n - 1) == input + n - 2);
+
+ ASSERT (memchr (input, 'f', n) == NULL);
+ ASSERT (memchr (input, '\0', n) == NULL);
+
+ /* Check that a very long haystack is handled quickly if the byte is
+ found near the beginning. */
+ {
+ size_t repeat = 10000;
+ for (; repeat > 0; repeat--)
+ {
+ ASSERT (memchr (input, 'c', n) == input + 2);
+ }
+ }
+
+ /* Alignment tests. */
+ for (int i = 0; i < 32; i++)
{
- for (j = 0; j < 256; j++)
+ for (int j = 0; j < 256; j++)
input[i + j] = j;
- for (j = 0; j < 256; j++)
+ for (int j = 0; j < 256; j++)
{
ASSERT (memchr (input + i, j, 256) == input + i + j);
}
}
+
+ free (input);
}
/* Check that memchr() does not read past the first occurrence of the
if (page_boundary != NULL)
{
- for (n = 1; n <= limit; n++)
+ for (int n = 1; n <= limit; n++)
{
char *mem = page_boundary - n;
memset (mem, 'X', n);
ASSERT (memchr (mem, 'U', n) == NULL);
ASSERT (memchr (mem, 0, n) == NULL);
- {
- size_t i;
- size_t k;
-
- for (i = 0; i < n; i++)
- {
- mem[i] = 'U';
- for (k = i + 1; k < n + limit; k++)
- ASSERT (memchr (mem, 'U', k) == mem + i);
- mem[i] = 0;
- for (k = i + 1; k < n + limit; k++)
- ASSERT (memchr (mem, 0, k) == mem + i);
- mem[i] = 'X';
- }
- }
+ for (size_t i = 0; i < n; i++)
+ {
+ mem[i] = 'U';
+ for (size_t k = i + 1; k < n + limit; k++)
+ ASSERT (memchr (mem, 'U', k) == mem + i);
+ mem[i] = 0;
+ for (size_t k = i + 1; k < n + limit; k++)
+ ASSERT (memchr (mem, 0, k) == mem + i);
+ mem[i] = 'X';
+ }
}
}
}
- free (input);
-
/* Test zero-length operations on NULL pointers, allowed by
<https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3322.pdf>. */
ASSERT (memchr (NULL, '?', 0) == NULL);
}
/* Alignment tests. */
- {
- int i, j;
- for (i = 0; i < 32; i++)
- {
- for (j = 0; j < 256; j++)
- input[i + j] = j;
- for (j = 0; j < 256; j++)
- {
- ASSERT (memchr2 (input + i, j, 0xff, 256) == input + i + j);
- ASSERT (memchr2 (input + i, 0xff, j, 256) == input + i + j);
- }
- }
- }
+ for (int i = 0; i < 32; i++)
+ {
+ for (int j = 0; j < 256; j++)
+ input[i + j] = j;
+ for (int j = 0; j < 256; j++)
+ {
+ ASSERT (memchr2 (input + i, j, 0xff, 256) == input + i + j);
+ ASSERT (memchr2 (input + i, 0xff, j, 256) == input + i + j);
+ }
+ }
free (input);
{
char foo[21];
char bar[21];
- int i;
- for (i = 0; i < 4; i++)
+ for (int i = 0; i < 4; i++)
{
char *a = foo + i;
char *b = bar + i;
"with_multilib_list\n";
size_t h_len = strlen (h);
char *haystack = malloc (h_len + 1);
- size_t i;
ASSERT (haystack);
- for (i = 0; i < h_len - strlen (needle); i++)
+ for (size_t i = 0; i < h_len - strlen (needle); i++)
{
const char *p;
memcpy (haystack, h, h_len + 1);
}
/* Alignment tests. */
- {
- int i, j;
- for (i = 0; i < 32; i++)
- {
- for (j = 0; j < 256; j++)
- input[i + j] = j;
- for (j = 0; j < 256; j++)
- {
- ASSERT (memrchr (input + i, j, 256) == input + i + j);
- }
- }
- }
+ for (int i = 0; i < 32; i++)
+ {
+ for (int j = 0; j < 256; j++)
+ input[i + j] = j;
+ for (int j = 0; j < 256; j++)
+ {
+ ASSERT (memrchr (input + i, j, 256) == input + i + j);
+ }
+ }
free (input);
test_stack (void)
{
int count = 0;
- int repeat;
char *volatile last_stackbuf;
- for (repeat = 2 * 1000; repeat > 0; repeat--)
+ for (int repeat = 2 * 1000; repeat > 0; repeat--)
{
/* This odd way of writing two consecutive statements
do_secret_stuff (1, &last_stackbuf);
int
main (void)
{
- int i;
test_func funcs[2] = { mkfifoat, test_mknodat };
int result;
ASSERT (test_mkfifo (do_mknodat, false) == result);
/* Test directory-relative handling of both functions. */
- for (i = 0; i < 2; i++)
+ for (int i = 0; i < 2; i++)
{
struct stat st;
test_func func = funcs[i];
static void
test_function (void)
{
- int i;
const DOUBLE TWO_MANT_DIG =
/* Assume MANT_DIG <= 5 * 31.
Use the identity
* (DOUBLE) (1U << ((MANT_DIG - 1 + 4) / 5));
/* Randomized tests. */
- for (i = 0; i < SIZEOF (RANDOM); i++)
+ for (int i = 0; i < SIZEOF (RANDOM); i++)
{
DOUBLE x = RANDOM[i]; /* 0.0 <= x < 1.0 */
DOUBLE y;
main (void)
{
struct mount_entry *mounts;
- struct mount_entry *p;
mounts = read_file_system_list (false);
/* Assume at least one mount point. */
ASSERT (mounts != NULL);
- for (p = mounts; p != NULL;)
+ for (struct mount_entry *p = mounts; p != NULL;)
{
struct mount_entry *next = p->me_next;
printf ("%s %s %s %s %s\n",
static void
check_accounts (void)
{
- int i, sum;
+ int sum;
sum = 0;
- for (i = 0; i < ACCOUNT_COUNT; i++)
+ for (int i = 0; i < ACCOUNT_COUNT; i++)
sum += account[i];
if (sum != ACCOUNT_COUNT * 1000)
abort ();
static int
lock_mutator_thread (void *arg)
{
- int repeat;
-
- for (repeat = REPEAT_COUNT; repeat > 0; repeat--)
+ for (int repeat = REPEAT_COUNT; repeat > 0; repeat--)
{
int i1, i2, value;
static void
test_mtx_plain (void)
{
- int i;
thrd_t checkerthread;
thrd_t threads[THREAD_COUNT];
/* Initialization. */
- for (i = 0; i < ACCOUNT_COUNT; i++)
+ for (int i = 0; i < ACCOUNT_COUNT; i++)
account[i] = 1000;
init_atomic_int (&lock_checker_done);
set_atomic_int_value (&lock_checker_done, 0);
/* Spawn the threads. */
ASSERT (thrd_create (&checkerthread, lock_checker_thread, NULL)
== thrd_success);
- for (i = 0; i < THREAD_COUNT; i++)
+ for (int i = 0; i < THREAD_COUNT; i++)
ASSERT (thrd_create (&threads[i], lock_mutator_thread, NULL)
== thrd_success);
/* Wait for the threads to terminate. */
- for (i = 0; i < THREAD_COUNT; i++)
+ for (int i = 0; i < THREAD_COUNT; i++)
ASSERT (thrd_join (threads[i], NULL) == thrd_success);
set_atomic_int_value (&lock_checker_done, 1);
ASSERT (thrd_join (checkerthread, NULL) == thrd_success);
static int
reclock_mutator_thread (void *arg)
{
- int repeat;
-
- for (repeat = REPEAT_COUNT; repeat > 0; repeat--)
+ for (int repeat = REPEAT_COUNT; repeat > 0; repeat--)
{
recshuffle ();
static void
test_mtx_recursive (void)
{
- int i;
thrd_t checkerthread;
thrd_t threads[THREAD_COUNT];
/* Initialization. */
- for (i = 0; i < ACCOUNT_COUNT; i++)
+ for (int i = 0; i < ACCOUNT_COUNT; i++)
account[i] = 1000;
init_atomic_int (&reclock_checker_done);
set_atomic_int_value (&reclock_checker_done, 0);
/* Spawn the threads. */
ASSERT (thrd_create (&checkerthread, reclock_checker_thread, NULL)
== thrd_success);
- for (i = 0; i < THREAD_COUNT; i++)
+ for (int i = 0; i < THREAD_COUNT; i++)
ASSERT (thrd_create (&threads[i], reclock_mutator_thread, NULL)
== thrd_success);
/* Wait for the threads to terminate. */
- for (i = 0; i < THREAD_COUNT; i++)
+ for (int i = 0; i < THREAD_COUNT; i++)
ASSERT (thrd_join (threads[i], NULL) == thrd_success);
set_atomic_int_value (&reclock_checker_done, 1);
ASSERT (thrd_join (checkerthread, NULL) == thrd_success);
{
#if HAVE_WORKING_USELOCALE
/* Check that nl_langinfo() uses the per-thread locale. */
- int pass;
bool skipped_all = true;
/* Extract a few items from the C locale. */
ASSERT (strlen (c_CRNCYSTR) <= 1); /* "-", "+", ".", or "" */
ASSERT (c_strcasestr (c_YESEXPR, "y" /* from "yes" */) != NULL);
- for (pass = 1; pass <= 2; pass++)
+ for (int pass = 1; pass <= 2; pass++)
{
/* pass locale
1 traditional French locale
init_data (size_t data_block_size)
{
unsigned char *data;
- unsigned int i;
data = (unsigned char *) malloc (2 * data_block_size);
ASSERT (data != NULL);
- for (i = 0; i < 2 * data_block_size; i++)
+ for (unsigned int i = 0; i < 2 * data_block_size; i++)
data[i] = (unsigned char) (i * i + (7 * i) % 61 + 4);
return data;
posixtm_test (void)
{
int fail = 0;
- unsigned int i;
- for (i = 0; T[i].fmt; i++)
+ for (unsigned int i = 0; T[i].fmt; i++)
{
char buf[1000];
time_t t = T[i].in;
tzalloc_test (void)
{
int fail = 0;
- int i;
- for (i = 0; LT[i].tza; i++)
+ for (int i = 0; LT[i].tza; i++)
{
struct tzalloc_test *tza = LT[i].tza;
long lt = LT[i].t;
quarter_test (void)
{
int fail = 0;
- size_t mon;
/* Check %q. */
- for (mon = 1; mon <= 12; mon++)
+ for (size_t mon = 1; mon <= 12; mon++)
{
char out[2];
char exp[2] = {0,};
char *base = obstack_base (&obs);
char *new_base;
RETTYPE result;
- int i;
ASSERT (obstack_chunk_size (&obs) < 10000);
result = my_obstack_printf (&obs, "%010000d", 0);
ASSERT (result == obstack_object_size (&obs));
new_base = obstack_base (&obs);
ASSERT (base != new_base);
- for (i = 0; i < 10000; i++)
+ for (int i = 0; i < 10000; i++)
ASSERT (new_base[i] == '0');
}
{
char *s = obstack_finish (&obs);
ASSERT (len == n1 + n2 + 3);
- size_t i;
- for (i = 0; i < len; i++)
+ for (size_t i = 0; i < len; i++)
s[i] = (i == 0 ? 'x' :
i <= n1 ? 'a' :
i == n1 + 1 ? 'y' :
{
char *s = obstack_finish (&obs);
ASSERT (len == n1 + 2);
- size_t i;
- for (i = 0; i < len; i++)
+ for (size_t i = 0; i < len; i++)
s[i] = (i == 0 ? 'x' :
i <= n1 ? 'a' :
i == n1 + 1 ? 'y' :
{
char *s = obstack_finish (&obs);
ASSERT (len == n1 + 2);
- size_t i;
- for (i = 0; i < len; i++)
+ for (size_t i = 0; i < len; i++)
s[i] = (i == 0 ? 'x' :
i <= n1 ? 'a' :
i == n1 + 1 ? 'y' :
ASSERT (len >= 0);
char *result = obstack_finish (&obs);
ASSERT (len == 4000 + 3);
- size_t i;
- for (i = 0; i < 4000 - 7; i++)
+ for (size_t i = 0; i < 4000 - 7; i++)
ASSERT (result[i] == '0');
ASSERT (memcmp (result + 4000 - 7, "1234567 99", 7 + 3) == 0);
obstack_free (&obs, result);
{
/* Since the O_CLOEXEC handling goes through a special code path at its
first invocation, test it twice. */
- int i;
-
- for (i = 0; i < 2; i++)
+ for (int i = 0; i < 2; i++)
{
int flags;
int
main (void)
{
- int i;
- int j;
int dfd;
int fd;
char buf[2];
/* Four iterations, with progressively more standard descriptors
closed. */
- for (i = -1; i <= STDERR_FILENO; i++)
+ for (int i = -1; i <= STDERR_FILENO; i++)
{
ASSERT (fchdir (dfd) == 0);
if (0 <= i)
ASSERT (close (i) == 0);
/* Execute once in ".", once in "..". */
- for (j = 0; j <= 1; j++)
+ for (int j = 0; j <= 1; j++)
{
if (j)
ASSERT (chdir ("..") == 0);
static void
test_getopt_long (void)
{
- int start;
-
/* Test disambiguation of options. */
{
static const struct program_option options[] =
};
/* Test processing of boolean short options. */
- for (start = 0; start <= 1; start++)
+ for (int start = 0; start <= 1; start++)
{
const char *p_value = NULL;
const char *q_value = NULL;
ASSERT (unrecognized == 0);
ASSERT (optind == 2);
}
- for (start = 0; start <= 1; start++)
+ for (int start = 0; start <= 1; start++)
{
const char *p_value = NULL;
const char *q_value = NULL;
ASSERT (unrecognized == 0);
ASSERT (optind == 3);
}
- for (start = 0; start <= 1; start++)
+ for (int start = 0; start <= 1; start++)
{
const char *p_value = NULL;
const char *q_value = NULL;
ASSERT (unrecognized == 0);
ASSERT (optind == 2);
}
- for (start = 0; start <= 1; start++)
+ for (int start = 0; start <= 1; start++)
{
const char *p_value = NULL;
const char *q_value = NULL;
}
/* Test processing of boolean long options. */
- for (start = 0; start <= 1; start++)
+ for (int start = 0; start <= 1; start++)
{
const char *p_value = NULL;
const char *q_value = NULL;
ASSERT (unrecognized == 0);
ASSERT (optind == 2);
}
- for (start = 0; start <= 1; start++)
+ for (int start = 0; start <= 1; start++)
{
const char *p_value = NULL;
const char *q_value = NULL;
ASSERT (unrecognized == 0);
ASSERT (optind == 3);
}
- for (start = 0; start <= 1; start++)
+ for (int start = 0; start <= 1; start++)
{
const char *p_value = NULL;
const char *q_value = NULL;
};
/* Test processing of short options with arguments. */
- for (start = 0; start <= 1; start++)
+ for (int start = 0; start <= 1; start++)
{
const char *p_value = NULL;
const char *q_value = NULL;
ASSERT (unrecognized == 0);
ASSERT (optind == 2);
}
- for (start = 0; start <= 1; start++)
+ for (int start = 0; start <= 1; start++)
{
const char *p_value = NULL;
const char *q_value = NULL;
ASSERT (unrecognized == 0);
ASSERT (optind == 3);
}
- for (start = 0; start <= 1; start++)
+ for (int start = 0; start <= 1; start++)
{
const char *p_value = NULL;
const char *q_value = NULL;
}
/* Test processing of long options with arguments. */
- for (start = 0; start <= 1; start++)
+ for (int start = 0; start <= 1; start++)
{
const char *p_value = NULL;
const char *q_value = NULL;
ASSERT (unrecognized == 0);
ASSERT (optind == 2);
}
- for (start = 0; start <= 1; start++)
+ for (int start = 0; start <= 1; start++)
{
const char *p_value = NULL;
const char *q_value = NULL;
ASSERT (unrecognized == 0);
ASSERT (optind == 3);
}
- for (start = 0; start <= 1; start++)
+ for (int start = 0; start <= 1; start++)
{
const char *p_value = NULL;
const char *q_value = NULL;
};
/* Test processing of short options with optional arguments. */
- for (start = 0; start <= 1; start++)
+ for (int start = 0; start <= 1; start++)
{
const char *p_value = NULL;
const char *q_value = NULL;
ASSERT (unrecognized == 0);
ASSERT (optind == 2);
}
- for (start = 0; start <= 1; start++)
+ for (int start = 0; start <= 1; start++)
{
const char *p_value = NULL;
const char *q_value = NULL;
ASSERT (unrecognized == 0);
ASSERT (optind == 2);
}
- for (start = 0; start <= 1; start++)
+ for (int start = 0; start <= 1; start++)
{
const char *p_value = NULL;
const char *q_value = NULL;
}
/* Test processing of long options with optional arguments. */
- for (start = 0; start <= 1; start++)
+ for (int start = 0; start <= 1; start++)
{
const char *p_value = NULL;
const char *q_value = NULL;
ASSERT (unrecognized == 0);
ASSERT (optind == 2);
}
- for (start = 0; start <= 1; start++)
+ for (int start = 0; start <= 1; start++)
{
const char *p_value = NULL;
const char *q_value = NULL;
ASSERT (unrecognized == 0);
ASSERT (optind == 2);
}
- for (start = 0; start <= 1; start++)
+ for (int start = 0; start <= 1; start++)
{
const char *p_value = NULL;
const char *q_value = NULL;
ASSERT (unrecognized == 0);
ASSERT (optind == 2);
}
- for (start = 0; start <= 1; start++)
+ for (int start = 0; start <= 1; start++)
{
const char *p_value = NULL;
const char *q_value = NULL;
};
/* Check that invalid options are recognized. */
- for (start = 0; start <= 1; start++)
+ for (int start = 0; start <= 1; start++)
{
const char *p_value = NULL;
const char *q_value = NULL;
ASSERT (unrecognized == 'x');
ASSERT (optind == 5);
}
- for (start = 0; start <= 1; start++)
+ for (int start = 0; start <= 1; start++)
{
const char *p_value = NULL;
const char *q_value = NULL;
}
/* Check that unexpected arguments are recognized. */
- for (start = 0; start <= 1; start++)
+ for (int start = 0; start <= 1; start++)
{
const char *p_value = NULL;
const char *q_value = NULL;
ASSERT (unrecognized == 'a');
ASSERT (optind == 4);
}
- for (start = 0; start <= 1; start++)
+ for (int start = 0; start <= 1; start++)
{
const char *p_value = NULL;
const char *q_value = NULL;
}
/* Check that by default, non-options arguments are moved to the end. */
- for (start = 0; start <= 1; start++)
+ for (int start = 0; start <= 1; start++)
{
const char *p_value = NULL;
const char *q_value = NULL;
}
/* Check that '--' ends the argument processing. */
- for (start = 0; start <= 1; start++)
+ for (int start = 0; start <= 1; start++)
{
const char *p_value = NULL;
const char *q_value = NULL;
/* Check that the PROCESS_NON_OPTIONS flag causes non-options to be
returned in order. */
- for (start = 0; start <= 1; start++)
+ for (int start = 0; start <= 1; start++)
{
const char *p_value = NULL;
const char *q_value = NULL;
}
/* Check that '--' ends the argument processing. */
- for (start = 0; start <= 1; start++)
+ for (int start = 0; start <= 1; start++)
{
const char *p_value = NULL;
const char *q_value = NULL;
/* Check that the NON_OPTION_TERMINATES_OPTIONS flag causes the first
non-option to terminate the loop. */
- for (start = 0; start <= 1; start++)
+ for (int start = 0; start <= 1; start++)
{
const char *p_value = NULL;
const char *q_value = NULL;
ASSERT (unrecognized == 0);
ASSERT (optind == 1);
}
- for (start = 0; start <= 1; start++)
+ for (int start = 0; start <= 1; start++)
{
const char *p_value = NULL;
const char *q_value = NULL;
}
/* Check that '--' ends the argument processing. */
- for (start = 0; start <= 1; start++)
+ for (int start = 0; start <= 1; start++)
{
const char *p_value = NULL;
const char *q_value = NULL;
static void
test_getopt_long_posix (void)
{
- int start;
-
{
static const struct program_option options[] =
{
};
/* Check that POSIXLY_CORRECT stops parsing the same as leading '+'. */
- for (start = 0; start <= 1; start++)
+ for (int start = 0; start <= 1; start++)
{
const char *p_value = NULL;
const char *q_value = NULL;
};
/* Check that POSIXLY_CORRECT doesn't change optional arguments. */
- for (start = 0; start <= 1; start++)
+ for (int start = 0; start <= 1; start++)
{
const char *p_value = NULL;
const char *q_value = NULL;
};
/* Check that leading - still sees options after non-options. */
- for (start = 0; start <= 1; start++)
+ for (int start = 0; start <= 1; start++)
{
const char *p_value = NULL;
const char *q_value = NULL;
size_t pagesize = getpagesize ();
- int i;
- for (i = 0; i < n; i++)
+ for (int i = 0; i < n; i++)
pages[i] = pagealign_xalloc (pagesize);
/* Free half of the pages in allocation order and the other half of the pages
in reverse allocation order. */
int half = n / 2;
- for (i = 0; i < half; i++)
+ for (int i = 0; i < half; i++)
pagealign_free (pages[i]);
- for (i = n - 1; i >= half; i--)
+ for (int i = n - 1; i >= half; i--)
pagealign_free (pages[i]);
return 0;
struct timespec expected;
struct timespec now;
const char *p;
- int i;
long gmtoff;
time_t ref_time = 1304250918;
/* Check that some "next Monday", "last Wednesday", etc. are correct. */
ASSERT (setenv ("TZ", "UTC0", 1) == 0);
tzset ();
- for (i = 0; day_table[i]; i++)
+ for (int i = 0; day_table[i]; i++)
{
unsigned int thur2 = SOME_TIMEPOINT + 7 * 24 * 3600; /* 2nd thursday */
char tmp[32];
/* Test that perror uses the same message as strerror. */
{
int errs[] = { EACCES, 0, -3, };
- int i;
- for (i = 0; i < SIZEOF (errs); i++)
+ for (int i = 0; i < SIZEOF (errs); i++)
{
char buf[256];
const char *err = strerror (errs[i]);
struct locals *l = (struct locals *) private_data;
const char *p = l->input + l->nread;
const char *q = (const char *) data_read;
- size_t i;
- for (i = 0; i < num_bytes_read; i++, q++)
+ for (size_t i = 0; i < num_bytes_read; i++, q++)
{
/* Handle conversion NL -> CRLF possibly done by the child process. */
if (!(O_BINARY && *q == '\r'))
struct locals *l = (struct locals *) private_data;
const char *p = l->input + l->nread;
const char *q = (const char *) data_read;
- size_t i;
- for (i = 0; i < num_bytes_read; i++, q++)
+ for (size_t i = 0; i < num_bytes_read; i++, q++)
{
/* Handle conversion NL -> CRLF possibly done by the child process. */
if (!(O_BINARY && *q == '\r'))
int
main ()
{
- int use_nonblocking;
- int use_cloexec;
-
- for (use_nonblocking = 0; use_nonblocking <= !!O_NONBLOCK; use_nonblocking++)
- for (use_cloexec = 0; use_cloexec <= !!O_CLOEXEC; use_cloexec++)
+ for (int use_nonblocking = 0; use_nonblocking <= !!O_NONBLOCK; use_nonblocking++)
+ for (int use_cloexec = 0; use_cloexec <= !!O_CLOEXEC; use_cloexec++)
{
int o_flags;
int fd[2];
{
size_t len;
char *cmd;
- int i;
/* Children - use the pipe. */
if (argc > 1)
strcpy (cmd, argv[0]);
cmd[len] = ' ';
cmd[len + 2] = '\0';
- for (i = 0; i < 2; i++)
+ for (int i = 0; i < 2; i++)
{
FILE *child;
int status;
void *aligned16_blocks[SIZEOF (sizes)];
void *aligned32_blocks[SIZEOF (sizes)];
void *aligned64_blocks[SIZEOF (sizes)];
- size_t i;
- for (i = 0; i < SIZEOF (sizes); i++)
+ for (size_t i = 0; i < SIZEOF (sizes); i++)
{
size_t size = sizes[i];
memset (aligned64_blocks[i], 'z', size);
}
- for (i = 0; i < SIZEOF (sizes); i++)
+ for (size_t i = 0; i < SIZEOF (sizes); i++)
{
if (sizeof (void *) <= 2)
free (aligned2_blocks[i]);
O_RDWR | O_CREAT | O_TRUNC, 0600)
== 0);
- {
- size_t i;
-
- for (i = 0; i < 2; i++)
- {
- const char *prog_path =
- (i == 0 ? SRCDIR "executable-script" : SRCDIR "executable-script.sh");
- const char *prog_argv[2] = { prog_path, NULL };
-
- int err = posix_spawn (&child, prog_path, &actions, NULL,
- (char **) prog_argv, environ);
- if (err != ENOEXEC)
- {
- if (err != 0)
- {
- errno = err;
- perror ("posix_spawn");
- return 1;
- }
-
- /* Wait for child. */
- int status = 0;
- while (waitpid (child, &status, 0) != child)
- ;
- if (!WIFEXITED (status))
- {
- fprintf (stderr, "subprocess terminated with unexpected wait status %d\n", status);
- return 1;
- }
- int exitstatus = WEXITSTATUS (status);
- if (exitstatus != 127)
- {
- fprintf (stderr, "subprocess terminated with unexpected exit status %d\n", exitstatus);
- return 1;
- }
- }
- }
- }
+ for (size_t i = 0; i < 2; i++)
+ {
+ const char *prog_path =
+ (i == 0 ? SRCDIR "executable-script" : SRCDIR "executable-script.sh");
+ const char *prog_argv[2] = { prog_path, NULL };
+
+ int err = posix_spawn (&child, prog_path, &actions, NULL,
+ (char **) prog_argv, environ);
+ if (err != ENOEXEC)
+ {
+ if (err != 0)
+ {
+ errno = err;
+ perror ("posix_spawn");
+ return 1;
+ }
+
+ /* Wait for child. */
+ int status = 0;
+ while (waitpid (child, &status, 0) != child)
+ ;
+ if (!WIFEXITED (status))
+ {
+ fprintf (stderr, "subprocess terminated with unexpected wait status %d\n", status);
+ return 1;
+ }
+ int exitstatus = WEXITSTATUS (status);
+ if (exitstatus != 127)
+ {
+ fprintf (stderr, "subprocess terminated with unexpected exit status %d\n", exitstatus);
+ return 1;
+ }
+ }
+ }
#if defined _WIN32 && !defined __CYGWIN__
/* On native Windows, scripts - even with '#!' marker - are not executable.
O_RDWR | O_CREAT | O_TRUNC, 0600)
== 0);
- {
- size_t i;
-
- for (i = 0; i < 2; i++)
- {
- const char *prog_path =
- (i == 0 ? SRCDIR "executable-script" : SRCDIR "executable-script.sh");
- const char *prog_argv[2] = { prog_path, NULL };
-
- int err = posix_spawnp (&child, prog_path, &actions, NULL,
- (char **) prog_argv, environ);
- if (err != ENOEXEC)
- {
- if (err != 0)
- {
- errno = err;
- perror ("posix_spawn");
- return 1;
- }
-
- /* Wait for child. */
- int status = 0;
- while (waitpid (child, &status, 0) != child)
- ;
- if (!WIFEXITED (status))
- {
- fprintf (stderr, "subprocess terminated with unexpected wait status %d\n", status);
- return 1;
- }
- int exitstatus = WEXITSTATUS (status);
- if (exitstatus != 127)
- {
- fprintf (stderr, "subprocess terminated with unexpected exit status %d\n", exitstatus);
- return 1;
- }
- }
- }
- }
+ for (size_t i = 0; i < 2; i++)
+ {
+ const char *prog_path =
+ (i == 0 ? SRCDIR "executable-script" : SRCDIR "executable-script.sh");
+ const char *prog_argv[2] = { prog_path, NULL };
+
+ int err = posix_spawnp (&child, prog_path, &actions, NULL,
+ (char **) prog_argv, environ);
+ if (err != ENOEXEC)
+ {
+ if (err != 0)
+ {
+ errno = err;
+ perror ("posix_spawn");
+ return 1;
+ }
+
+ /* Wait for child. */
+ int status = 0;
+ while (waitpid (child, &status, 0) != child)
+ ;
+ if (!WIFEXITED (status))
+ {
+ fprintf (stderr, "subprocess terminated with unexpected wait status %d\n", status);
+ return 1;
+ }
+ int exitstatus = WEXITSTATUS (status);
+ if (exitstatus != 127)
+ {
+ fprintf (stderr, "subprocess terminated with unexpected exit status %d\n", exitstatus);
+ return 1;
+ }
+ }
+ }
#if defined _WIN32 && !defined __CYGWIN__
/* On native Windows, scripts - even with '#!' marker - are not executable.
int
main (void)
{
- unsigned int i;
char curr_year_str[30];
struct tm *tm;
time_t t_now;
n_bytes = strftime (curr_year_str, sizeof curr_year_str, "%Y", tm);
ASSERT (0 < n_bytes);
- for (i = 0; T[i].in; i++)
+ for (unsigned int i = 0; T[i].in; i++)
{
time_t t_out;
time_t t_exp;
char const *file = "in";
int fd;
char buf[] = "0123456789";
- off_t pos;
ASSERT (file);
fd = open (file, O_RDONLY);
ASSERT (0 <= fd);
- for (pos = 0; pos < 3; pos++)
+ for (off_t pos = 0; pos < 3; pos++)
{
- size_t i;
off_t init_pos = lseek (fd, pos, SEEK_SET);
ASSERT (init_pos == pos);
- for (i = 0; i < N; i++)
+ for (size_t i = 0; i < N; i++)
{
char byte_buf;
ASSERT (pread (fd, &byte_buf, 1, i) == 1);
static void
check_accounts (void)
{
- int i, sum;
+ int sum;
sum = 0;
- for (i = 0; i < ACCOUNT_COUNT; i++)
+ for (int i = 0; i < ACCOUNT_COUNT; i++)
sum += account[i];
if (sum != ACCOUNT_COUNT * 1000)
abort ();
static void *
lock_mutator_thread (void *arg)
{
- int repeat;
-
- for (repeat = REPEAT_COUNT; repeat > 0; repeat--)
+ for (int repeat = REPEAT_COUNT; repeat > 0; repeat--)
{
int i1, i2, value;
static void
test_pthread_mutex_normal (void)
{
- int i;
pthread_t checkerthread;
pthread_t threads[THREAD_COUNT];
/* Initialization. */
- for (i = 0; i < ACCOUNT_COUNT; i++)
+ for (int i = 0; i < ACCOUNT_COUNT; i++)
account[i] = 1000;
init_atomic_int (&lock_checker_done);
set_atomic_int_value (&lock_checker_done, 0);
/* Spawn the threads. */
ASSERT (pthread_create (&checkerthread, NULL, lock_checker_thread, NULL)
== 0);
- for (i = 0; i < THREAD_COUNT; i++)
+ for (int i = 0; i < THREAD_COUNT; i++)
ASSERT (pthread_create (&threads[i], NULL, lock_mutator_thread, NULL) == 0);
/* Wait for the threads to terminate. */
- for (i = 0; i < THREAD_COUNT; i++)
+ for (int i = 0; i < THREAD_COUNT; i++)
ASSERT (pthread_join (threads[i], NULL) == 0);
set_atomic_int_value (&lock_checker_done, 1);
ASSERT (pthread_join (checkerthread, NULL) == 0);
static void *
reclock_mutator_thread (void *arg)
{
- int repeat;
-
- for (repeat = REPEAT_COUNT; repeat > 0; repeat--)
+ for (int repeat = REPEAT_COUNT; repeat > 0; repeat--)
{
recshuffle ();
static void
test_pthread_mutex_recursive (void)
{
- int i;
pthread_t checkerthread;
pthread_t threads[THREAD_COUNT];
/* Initialization. */
- for (i = 0; i < ACCOUNT_COUNT; i++)
+ for (int i = 0; i < ACCOUNT_COUNT; i++)
account[i] = 1000;
init_atomic_int (&reclock_checker_done);
set_atomic_int_value (&reclock_checker_done, 0);
/* Spawn the threads. */
ASSERT (pthread_create (&checkerthread, NULL, reclock_checker_thread, NULL)
== 0);
- for (i = 0; i < THREAD_COUNT; i++)
+ for (int i = 0; i < THREAD_COUNT; i++)
ASSERT (pthread_create (&threads[i], NULL, reclock_mutator_thread, NULL)
== 0);
/* Wait for the threads to terminate. */
- for (i = 0; i < THREAD_COUNT; i++)
+ for (int i = 0; i < THREAD_COUNT; i++)
ASSERT (pthread_join (threads[i], NULL) == 0);
set_atomic_int_value (&reclock_checker_done, 1);
ASSERT (pthread_join (checkerthread, NULL) == 0);
once_contender_thread (void *arg)
{
int id = (int) (intptr_t) arg;
- int repeat;
- for (repeat = 0; repeat <= REPEAT_COUNT; repeat++)
+ for (int repeat = 0; repeat <= REPEAT_COUNT; repeat++)
{
/* Tell the main thread that we're ready. */
ASSERT (pthread_mutex_lock (&ready_lock[id]) == 0);
static void
test_once (void)
{
- int i, repeat;
pthread_t threads[THREAD_COUNT];
/* Initialize all variables. */
- for (i = 0; i < THREAD_COUNT; i++)
+ for (int i = 0; i < THREAD_COUNT; i++)
{
pthread_mutexattr_t attr;
ASSERT (pthread_mutexattr_destroy (&attr) == 0);
}
#if ENABLE_LOCKING
- for (i = 0; i < REPEAT_COUNT; i++)
+ for (int i = 0; i < REPEAT_COUNT; i++)
ASSERT (pthread_rwlock_init (&fire_signal[i], NULL) == 0);
#else
fire_signal_state = 0;
#if ENABLE_LOCKING
/* Block all fire_signals. */
- for (i = REPEAT_COUNT-1; i >= 0; i--)
+ for (int i = REPEAT_COUNT-1; i >= 0; i--)
ASSERT (pthread_rwlock_wrlock (&fire_signal[i]) == 0);
#endif
/* Spawn the threads. */
- for (i = 0; i < THREAD_COUNT; i++)
+ for (int i = 0; i < THREAD_COUNT; i++)
ASSERT (pthread_create (&threads[i], NULL,
once_contender_thread, (void *) (intptr_t) i)
== 0);
- for (repeat = 0; repeat <= REPEAT_COUNT; repeat++)
+ for (int repeat = 0; repeat <= REPEAT_COUNT; repeat++)
{
/* Wait until every thread is ready. */
dbgprintf ("Main thread before synchronizing for round %d\n", repeat);
for (;;)
{
int ready_count = 0;
- for (i = 0; i < THREAD_COUNT; i++)
+ for (int i = 0; i < THREAD_COUNT; i++)
{
ASSERT (pthread_mutex_lock (&ready_lock[i]) == 0);
ready_count += ready[i];
performed = 0;
/* Preparation for the next round: Reset the ready flags. */
- for (i = 0; i < THREAD_COUNT; i++)
+ for (int i = 0; i < THREAD_COUNT; i++)
{
ASSERT (pthread_mutex_lock (&ready_lock[i]) == 0);
ready[i] = 0;
}
/* Wait for the threads to terminate. */
- for (i = 0; i < THREAD_COUNT; i++)
+ for (int i = 0; i < THREAD_COUNT; i++)
ASSERT (pthread_join (threads[i], NULL) == 0);
}
static void
check_accounts (void)
{
- int i, sum;
+ int sum;
sum = 0;
- for (i = 0; i < ACCOUNT_COUNT; i++)
+ for (int i = 0; i < ACCOUNT_COUNT; i++)
sum += account[i];
if (sum != ACCOUNT_COUNT * 1000)
abort ();
static void *
rwlock_mutator_thread (void *arg)
{
- int repeat;
-
- for (repeat = REPEAT_COUNT; repeat > 0; repeat--)
+ for (int repeat = REPEAT_COUNT; repeat > 0; repeat--)
{
int i1, i2, value;
static void
test_rwlock (void)
{
- int i;
pthread_t checkerthreads[THREAD_COUNT];
pthread_t threads[THREAD_COUNT];
/* Initialization. */
- for (i = 0; i < ACCOUNT_COUNT; i++)
+ for (int i = 0; i < ACCOUNT_COUNT; i++)
account[i] = 1000;
init_atomic_int (&rwlock_checker_done);
set_atomic_int_value (&rwlock_checker_done, 0);
/* Spawn the threads. */
- for (i = 0; i < THREAD_COUNT; i++)
+ for (int i = 0; i < THREAD_COUNT; i++)
ASSERT (pthread_create (&checkerthreads[i], NULL,
rwlock_checker_thread, NULL)
== 0);
- for (i = 0; i < THREAD_COUNT; i++)
+ for (int i = 0; i < THREAD_COUNT; i++)
ASSERT (pthread_create (&threads[i], NULL, rwlock_mutator_thread, NULL)
== 0);
/* Wait for the threads to terminate. */
- for (i = 0; i < THREAD_COUNT; i++)
+ for (int i = 0; i < THREAD_COUNT; i++)
ASSERT (pthread_join (threads[i], NULL) == 0);
set_atomic_int_value (&rwlock_checker_done, 1);
- for (i = 0; i < THREAD_COUNT; i++)
+ for (int i = 0; i < THREAD_COUNT; i++)
ASSERT (pthread_join (checkerthreads[i], NULL) == 0);
check_accounts ();
}
static void
check_accounts (void)
{
- int i, sum;
+ int sum;
sum = 0;
- for (i = 0; i < ACCOUNT_COUNT; i++)
+ for (int i = 0; i < ACCOUNT_COUNT; i++)
sum += account[i];
if (sum != ACCOUNT_COUNT * 1000)
abort ();
static void *
lock_mutator_thread (void *arg)
{
- int repeat;
-
- for (repeat = REPEAT_COUNT; repeat > 0; repeat--)
+ for (int repeat = REPEAT_COUNT; repeat > 0; repeat--)
{
int i1, i2, value;
static void
test_pthread_spin (void)
{
- int i;
pthread_t checkerthread;
pthread_t threads[THREAD_COUNT];
/* Initialization. */
- for (i = 0; i < ACCOUNT_COUNT; i++)
+ for (int i = 0; i < ACCOUNT_COUNT; i++)
account[i] = 1000;
init_atomic_int (&lock_checker_done);
set_atomic_int_value (&lock_checker_done, 0);
/* Spawn the threads. */
ASSERT (pthread_create (&checkerthread, NULL, lock_checker_thread, NULL)
== 0);
- for (i = 0; i < THREAD_COUNT; i++)
+ for (int i = 0; i < THREAD_COUNT; i++)
ASSERT (pthread_create (&threads[i], NULL, lock_mutator_thread, NULL) == 0);
/* Wait for the threads to terminate. */
- for (i = 0; i < THREAD_COUNT; i++)
+ for (int i = 0; i < THREAD_COUNT; i++)
ASSERT (pthread_join (threads[i], NULL) == 0);
set_atomic_int_value (&lock_checker_done, 1);
ASSERT (pthread_join (checkerthread, NULL) == 0);
worker_thread (void *arg)
{
unsigned int id = (unsigned int) (uintptr_t) arg;
- int i, j, repeat;
unsigned int values[KEYS_COUNT];
dbgprintf ("Worker %p started\n", pthread_self_pointer ());
/* Initialize the per-thread storage. */
- for (i = 0; i < KEYS_COUNT; i++)
+ for (int i = 0; i < KEYS_COUNT; i++)
{
values[i] = (((unsigned long) random () >> 3) % 1000000) * THREAD_COUNT + id;
/* Hopefully no arithmetic overflow. */
/* Verify that the initial value is NULL. */
dbgprintf ("Worker %p before initial verify\n", pthread_self_pointer ());
- for (i = 0; i < KEYS_COUNT; i++)
+ for (int i = 0; i < KEYS_COUNT; i++)
if (pthread_getspecific (mykeys[i]) != NULL)
abort ();
dbgprintf ("Worker %p after initial verify\n", pthread_self_pointer ());
/* Initialize the per-thread storage. */
dbgprintf ("Worker %p before first pthread_setspecific\n",
pthread_self_pointer ());
- for (i = 0; i < KEYS_COUNT; i++)
+ for (int i = 0; i < KEYS_COUNT; i++)
{
unsigned int *ptr = (unsigned int *) malloc (sizeof (unsigned int));
*ptr = values[i];
perhaps_yield ();
/* Shuffle around the pointers. */
- for (repeat = REPEAT_COUNT; repeat > 0; repeat--)
+ for (int repeat = REPEAT_COUNT; repeat > 0; repeat--)
{
dbgprintf ("Worker %p doing value swapping\n", pthread_self_pointer ());
- i = ((unsigned long) random () >> 3) % KEYS_COUNT;
- j = ((unsigned long) random () >> 3) % KEYS_COUNT;
+ int i = ((unsigned long) random () >> 3) % KEYS_COUNT;
+ int j = ((unsigned long) random () >> 3) % KEYS_COUNT;
if (i != j)
{
void *vi = pthread_getspecific (mykeys[i]);
/* Verify that all the values are from this thread. */
dbgprintf ("Worker %p before final verify\n", pthread_self_pointer ());
- for (i = 0; i < KEYS_COUNT; i++)
+ for (int i = 0; i < KEYS_COUNT; i++)
if ((*(unsigned int *) pthread_getspecific (mykeys[i]) % THREAD_COUNT)
!= id)
abort ();
static void
test_tss (void)
{
- int pass, i;
-
- for (pass = 0; pass < 2; pass++)
+ for (int pass = 0; pass < 2; pass++)
{
pthread_t threads[THREAD_COUNT];
if (pass == 0)
- for (i = 0; i < KEYS_COUNT; i++)
+ for (int i = 0; i < KEYS_COUNT; i++)
ASSERT (pthread_key_create (&mykeys[i], free) == 0);
else
- for (i = KEYS_COUNT - 1; i >= 0; i--)
+ for (int i = KEYS_COUNT - 1; i >= 0; i--)
ASSERT (pthread_key_create (&mykeys[i], free) == 0);
/* Spawn the threads. */
- for (i = 0; i < THREAD_COUNT; i++)
+ for (int i = 0; i < THREAD_COUNT; i++)
ASSERT (pthread_create (&threads[i], NULL,
worker_thread, (void *) (uintptr_t) i)
== 0);
/* Wait for the threads to terminate. */
- for (i = 0; i < THREAD_COUNT; i++)
+ for (int i = 0; i < THREAD_COUNT; i++)
ASSERT (pthread_join (threads[i], NULL) == 0);
- for (i = 0; i < KEYS_COUNT; i++)
+ for (int i = 0; i < KEYS_COUNT; i++)
ASSERT (pthread_key_delete (mykeys[i]) == 0);
}
}
{
unsigned int id = (unsigned int) (uintptr_t) arg;
pthread_key_t *keys = dtorcheck_keys[id]; /* an array of KEYS_COUNT keys */
- int i;
- for (i = 0; i < KEYS_COUNT; i++)
+ for (int i = 0; i < KEYS_COUNT; i++)
ASSERT (pthread_key_create (&keys[i], destructor_table[i]) == 0);
- for (i = 0; i < KEYS_COUNT; i++)
+ for (int i = 0; i < KEYS_COUNT; i++)
ASSERT (pthread_setspecific (keys[i],
(void *) (uintptr_t) (10 * id + i + 1))
== 0);
test_tss_dtorcheck1 (void)
{
pthread_t threads[THREAD_COUNT];
- unsigned int id;
- int i;
uintptr_t expected_sum;
sum = 0;
/* Spawn the threads. */
- for (id = 0; id < THREAD_COUNT; id++)
+ for (unsigned int id = 0; id < THREAD_COUNT; id++)
ASSERT (pthread_create (&threads[id], NULL,
dtorcheck1_thread, (void *) (uintptr_t) id)
== 0);
/* Wait for the threads to terminate. */
- for (id = 0; id < THREAD_COUNT; id++)
+ for (unsigned int id = 0; id < THREAD_COUNT; id++)
ASSERT (pthread_join (threads[id], NULL) == 0);
/* Clean up the keys. */
- for (id = 0; id < THREAD_COUNT; id++)
- for (i = 0; i < KEYS_COUNT; i++)
+ for (unsigned int id = 0; id < THREAD_COUNT; id++)
+ for (int i = 0; i < KEYS_COUNT; i++)
ASSERT (pthread_key_delete (dtorcheck_keys[id][i]) == 0);
/* Check that the destructor was invoked for each key. */
{
unsigned int id = (unsigned int) (uintptr_t) arg;
pthread_key_t *keys = dtorcheck_keys[id]; /* an array of KEYS_COUNT keys */
- int i;
- for (i = 0; i < KEYS_COUNT; i++)
+ for (int i = 0; i < KEYS_COUNT; i++)
ASSERT (pthread_key_create (&keys[i], destructor_table[id]) == 0);
- for (i = 0; i < KEYS_COUNT; i++)
+ for (int i = 0; i < KEYS_COUNT; i++)
ASSERT (pthread_setspecific (keys[i],
(void *) (uintptr_t) (10 * i + id + 1))
== 0);
test_tss_dtorcheck2 (void)
{
pthread_t threads[THREAD_COUNT];
- unsigned int id;
- int i;
uintptr_t expected_sum;
sum = 0;
/* Spawn the threads. */
- for (id = 0; id < THREAD_COUNT; id++)
+ for (unsigned int id = 0; id < THREAD_COUNT; id++)
ASSERT (pthread_create (&threads[id], NULL,
dtorcheck2_thread, (void *) (uintptr_t) id)
== 0);
/* Wait for the threads to terminate. */
- for (id = 0; id < THREAD_COUNT; id++)
+ for (unsigned int id = 0; id < THREAD_COUNT; id++)
ASSERT (pthread_join (threads[id], NULL) == 0);
/* Clean up the keys. */
- for (id = 0; id < THREAD_COUNT; id++)
- for (i = 0; i < KEYS_COUNT; i++)
+ for (unsigned int id = 0; id < THREAD_COUNT; id++)
+ for (int i = 0; i < KEYS_COUNT; i++)
ASSERT (pthread_key_delete (dtorcheck_keys[id][i]) == 0);
/* Check that the destructor was invoked for each key. */
{
unsigned int id = (unsigned int) (uintptr_t) arg;
pthread_key_t *keys = racecheck_keys[id]; /* an array of KEYS_COUNT keys */
- int repeat;
- int i;
dbgprintf ("Worker %p started\n", pthread_self_pointer ());
- for (i = 0; i < KEYS_COUNT; i++)
+ for (int i = 0; i < KEYS_COUNT; i++)
{
ASSERT (pthread_key_create (&keys[i], destructor_table[i]) == 0);
ASSERT (pthread_setspecific (keys[i],
== 0);
}
- for (repeat = REPEAT_COUNT; repeat > 0; repeat--)
+ for (int repeat = REPEAT_COUNT; repeat > 0; repeat--)
{
- i = ((unsigned long) random () >> 3) % KEYS_COUNT;
+ int i = ((unsigned long) random () >> 3) % KEYS_COUNT;
dbgprintf ("Worker %p reallocating key %d\n", pthread_self_pointer (), i);
ASSERT (pthread_key_delete (keys[i]) == 0);
ASSERT (pthread_key_create (&keys[i], destructor_table[i]) == 0);
test_tss_racecheck (void)
{
pthread_t threads[THREAD_COUNT];
- unsigned int id;
- int i;
uintptr_t expected_sum;
sum = 0;
/* Spawn the threads. */
- for (id = 0; id < THREAD_COUNT; id++)
+ for (unsigned int id = 0; id < THREAD_COUNT; id++)
ASSERT (pthread_create (&threads[id], NULL,
racecheck_thread, (void *) (uintptr_t) id)
== 0);
/* Wait for the threads to terminate. */
- for (id = 0; id < THREAD_COUNT; id++)
+ for (unsigned int id = 0; id < THREAD_COUNT; id++)
ASSERT (pthread_join (threads[id], NULL) == 0);
/* Clean up the keys. */
- for (id = 0; id < THREAD_COUNT; id++)
- for (i = 0; i < KEYS_COUNT; i++)
+ for (unsigned int id = 0; id < THREAD_COUNT; id++)
+ for (int i = 0; i < KEYS_COUNT; i++)
ASSERT (pthread_key_delete (racecheck_keys[id][i]) == 0);
/* Check that the destructor was invoked for each key. */
#elif defined __gnu_hurd__ /* Hurd */
/* Try various master names of Hurd: /dev/pty[p-q][0-9a-v] */
- {
- int char1;
- int char2;
-
- for (char1 = 'p'; char1 <= 'q'; char1++)
- for (char2 = '0'; char2 <= 'v'; (char2 == '9' ? char2 = 'a' : char2++))
- {
- char master_name[32];
- int fd;
+ for (int char1 = 'p'; char1 <= 'q'; char1++)
+ for (int char2 = '0'; char2 <= 'v'; (char2 == '9' ? char2 = 'a' : char2++))
+ {
+ char master_name[32];
+ int fd;
- sprintf (master_name, "/dev/pty%c%c", char1, char2);
- fd = open (master_name, O_RDONLY);
- if (fd >= 0)
- {
- char *result;
- char slave_name[32];
+ sprintf (master_name, "/dev/pty%c%c", char1, char2);
+ fd = open (master_name, O_RDONLY);
+ if (fd >= 0)
+ {
+ char *result;
+ char slave_name[32];
- result = ptsname (fd);
- ASSERT (result != NULL);
- sprintf (slave_name, "/dev/tty%c%c", char1, char2);
- ASSERT (same_slave (result, slave_name));
+ result = ptsname (fd);
+ ASSERT (result != NULL);
+ sprintf (slave_name, "/dev/tty%c%c", char1, char2);
+ ASSERT (same_slave (result, slave_name));
- close (fd);
- }
- }
- }
+ close (fd);
+ }
+ }
#else
/* Try various master names of Mac OS X: /dev/pty[p-w][0-9a-f] */
- {
- int char1;
- int char2;
+ for (int char1 = 'p'; char1 <= 'w'; char1++)
+ for (int char2 = '0'; char2 <= 'f'; (char2 == '9' ? char2 = 'a' : char2++))
+ {
+ char master_name[32];
+ int fd;
+
+ sprintf (master_name, "/dev/pty%c%c", char1, char2);
+ fd = open (master_name, O_RDONLY);
+ if (fd >= 0)
+ {
+ char *result;
+ char slave_name[32];
+
+ result = ptsname (fd);
+ ASSERT (result != NULL);
+ sprintf (slave_name, "/dev/tty%c%c", char1, char2);
+ ASSERT (same_slave (result, slave_name));
+
+ close (fd);
+ }
+ }
- for (char1 = 'p'; char1 <= 'w'; char1++)
- for (char2 = '0'; char2 <= 'f'; (char2 == '9' ? char2 = 'a' : char2++))
+ /* Try various master names of *BSD: /dev/pty[p-sP-S][0-9a-v] */
+ for (int upper = 0; upper <= 1; upper++)
+ for (int char1 = (upper ? 'P' : 'p'); char1 <= (upper ? 'S' : 's'); char1++)
+ for (int char2 = '0'; char2 <= 'v'; (char2 == '9' ? char2 = 'a' : char2++))
{
char master_name[32];
int fd;
close (fd);
}
}
- }
-
- /* Try various master names of *BSD: /dev/pty[p-sP-S][0-9a-v] */
- {
- int upper;
- int char1;
- int char2;
-
- for (upper = 0; upper <= 1; upper++)
- for (char1 = (upper ? 'P' : 'p'); char1 <= (upper ? 'S' : 's'); char1++)
- for (char2 = '0'; char2 <= 'v'; (char2 == '9' ? char2 = 'a' : char2++))
- {
- char master_name[32];
- int fd;
-
- sprintf (master_name, "/dev/pty%c%c", char1, char2);
- fd = open (master_name, O_RDONLY);
- if (fd >= 0)
- {
- char *result;
- char slave_name[32];
-
- result = ptsname (fd);
- ASSERT (result != NULL);
- sprintf (slave_name, "/dev/tty%c%c", char1, char2);
- ASSERT (same_slave (result, slave_name));
-
- close (fd);
- }
- }
- }
#endif
char buffer[256];
size_t len;
size_t buflen_max;
- size_t buflen;
int result;
len = strlen (slave);
buflen_max = len + 5;
if (buflen_max > sizeof buffer)
buflen_max = sizeof buffer;
- for (buflen = 0; buflen <= buflen_max; buflen++)
+ for (size_t buflen = 0; buflen <= buflen_max; buflen++)
{
memset (buffer, 'X', sizeof buffer);
result = ptsname_r (fd, buffer, buflen);
#elif defined __gnu_hurd__ /* Hurd */
/* Try various master names of Hurd: /dev/pty[p-q][0-9a-v] */
- {
- int char1;
- int char2;
-
- for (char1 = 'p'; char1 <= 'q'; char1++)
- for (char2 = '0'; char2 <= 'v'; (char2 == '9' ? char2 = 'a' : char2++))
- {
- char master_name[32];
- int fd;
+ for (int char1 = 'p'; char1 <= 'q'; char1++)
+ for (int char2 = '0'; char2 <= 'v'; (char2 == '9' ? char2 = 'a' : char2++))
+ {
+ char master_name[32];
+ int fd;
- sprintf (master_name, "/dev/pty%c%c", char1, char2);
- fd = open (master_name, O_RDONLY);
- if (fd >= 0)
- {
- char buffer[256];
- int result;
- char slave_name[32];
+ sprintf (master_name, "/dev/pty%c%c", char1, char2);
+ fd = open (master_name, O_RDONLY);
+ if (fd >= 0)
+ {
+ char buffer[256];
+ int result;
+ char slave_name[32];
- result = ptsname_r (fd, buffer, sizeof buffer);
- ASSERT (result == 0);
- sprintf (slave_name, "/dev/tty%c%c", char1, char2);
- ASSERT (same_slave (buffer, slave_name));
+ result = ptsname_r (fd, buffer, sizeof buffer);
+ ASSERT (result == 0);
+ sprintf (slave_name, "/dev/tty%c%c", char1, char2);
+ ASSERT (same_slave (buffer, slave_name));
- test_errors (fd, buffer);
+ test_errors (fd, buffer);
- close (fd);
- }
- }
- }
+ close (fd);
+ }
+ }
#else
/* Try various master names of Mac OS X: /dev/pty[p-w][0-9a-f] */
- {
- int char1;
- int char2;
+ for (int char1 = 'p'; char1 <= 'w'; char1++)
+ for (int char2 = '0'; char2 <= 'f'; (char2 == '9' ? char2 = 'a' : char2++))
+ {
+ char master_name[32];
+ int fd;
- for (char1 = 'p'; char1 <= 'w'; char1++)
- for (char2 = '0'; char2 <= 'f'; (char2 == '9' ? char2 = 'a' : char2++))
+ sprintf (master_name, "/dev/pty%c%c", char1, char2);
+ fd = open (master_name, O_RDONLY);
+ if (fd >= 0)
+ {
+ char buffer[256];
+ int result;
+ char slave_name[32];
+
+ result = ptsname_r (fd, buffer, sizeof buffer);
+ ASSERT (result == 0);
+ sprintf (slave_name, "/dev/tty%c%c", char1, char2);
+ ASSERT (same_slave (buffer, slave_name));
+
+ test_errors (fd, buffer);
+
+ /* This call hangs on AIX. */
+ close (fd);
+ }
+ }
+
+ /* Try various master names of *BSD: /dev/pty[p-sP-S][0-9a-v] */
+ for (int upper = 0; upper <= 1; upper++)
+ for (int char1 = (upper ? 'P' : 'p'); char1 <= (upper ? 'S' : 's'); char1++)
+ for (int char2 = '0'; char2 <= 'v'; (char2 == '9' ? char2 = 'a' : char2++))
{
char master_name[32];
int fd;
test_errors (fd, buffer);
- /* This call hangs on AIX. */
close (fd);
}
}
- }
-
- /* Try various master names of *BSD: /dev/pty[p-sP-S][0-9a-v] */
- {
- int upper;
- int char1;
- int char2;
-
- for (upper = 0; upper <= 1; upper++)
- for (char1 = (upper ? 'P' : 'p'); char1 <= (upper ? 'S' : 's'); char1++)
- for (char2 = '0'; char2 <= 'v'; (char2 == '9' ? char2 = 'a' : char2++))
- {
- char master_name[32];
- int fd;
-
- sprintf (master_name, "/dev/pty%c%c", char1, char2);
- fd = open (master_name, O_RDONLY);
- if (fd >= 0)
- {
- char buffer[256];
- int result;
- char slave_name[32];
-
- result = ptsname_r (fd, buffer, sizeof buffer);
- ASSERT (result == 0);
- sprintf (slave_name, "/dev/tty%c%c", char1, char2);
- ASSERT (same_slave (buffer, slave_name));
-
- test_errors (fd, buffer);
-
- close (fd);
- }
- }
- }
#endif
int fd;
char buf[] = "0123456789";
off_t pos = 2;
- size_t i;
off_t init_pos;
ASSERT (file);
init_pos = lseek (fd, pos, SEEK_SET);
ASSERT (init_pos == pos);
- for (i = 0; i < N; i+=2)
+ for (size_t i = 0; i < N; i+=2)
{
const char byte = 'W';
ASSERT (pwrite (fd, &byte, 1, i) == 1);
int
main (_GL_UNUSED int argc, char *argv[])
{
- int i;
bool ascii_only = MB_CUR_MAX == 1 && !isprint ((unsigned char) LQ[0]);
/* This part of the program is hard-wired to the C locale since it
testing for quoting of str7, use the ascii_only flag to decide
what to expect for the 8-bit data being quoted. */
ASSERT (!isprint ('\033'));
- for (i = literal_quoting_style; i <= clocale_quoting_style; i++)
+ for (int i = literal_quoting_style; i <= clocale_quoting_style; i++)
{
set_quoting_style (NULL, (enum quoting_style) i);
if (!(i == locale_quoting_style || i == clocale_quoting_style)
ASSERT (set_quoting_flags (NULL, 0) == QA_SPLIT_TRIGRAPHS);
- for (i = 0; i < sizeof custom_quotes / sizeof *custom_quotes; ++i)
+ for (int i = 0; i < sizeof custom_quotes / sizeof *custom_quotes; ++i)
{
set_custom_quoting (NULL,
custom_quotes[i][0], custom_quotes[i][1]);
random_invocator_thread (void *arg)
{
long *storage = (long *) arg;
- int repeat;
- for (repeat = 0; repeat < REPEAT_COUNT; repeat++)
+ for (int repeat = 0; repeat < REPEAT_COUNT; repeat++)
{
storage[repeat] = random ();
yield ();
/* First, get the expected sequence of random() results. */
srandom (seed);
long *expected = XNMALLOC (REPEAT_COUNT, long);
- {
- int repeat;
- for (repeat = 0; repeat < REPEAT_COUNT; repeat++)
- expected[repeat] = random ();
- }
+ for (int repeat = 0; repeat < REPEAT_COUNT; repeat++)
+ expected[repeat] = random ();
/* Then, run REPEAT_COUNT invocations of random() each, in THREAD_COUNT
separate threads. */
gl_thread_t threads[THREAD_COUNT];
long *thread_results[THREAD_COUNT];
srandom (seed);
- {
- int i;
- for (i = 0; i < THREAD_COUNT; i++)
- thread_results[i] = XNMALLOC (REPEAT_COUNT, long);
- for (i = 0; i < THREAD_COUNT; i++)
- threads[i] =
- gl_thread_create (random_invocator_thread, thread_results[i]);
- }
+ for (int i = 0; i < THREAD_COUNT; i++)
+ thread_results[i] = XNMALLOC (REPEAT_COUNT, long);
+ for (int i = 0; i < THREAD_COUNT; i++)
+ threads[i] = gl_thread_create (random_invocator_thread, thread_results[i]);
/* Wait for the threads to terminate. */
- {
- int i;
- for (i = 0; i < THREAD_COUNT; i++)
- gl_thread_join (threads[i], NULL);
- }
+ for (int i = 0; i < THREAD_COUNT; i++)
+ gl_thread_join (threads[i], NULL);
/* Finally, determine whether the threads produced the same sequence of
random() results. */
{
- int expected_index;
int result_index[THREAD_COUNT];
- int i;
- for (i = 0; i < THREAD_COUNT; i++)
+ for (int i = 0; i < THREAD_COUNT; i++)
result_index[i] = 0;
- for (expected_index = 0; expected_index < REPEAT_COUNT; expected_index++)
+ for (int expected_index = 0; expected_index < REPEAT_COUNT; expected_index++)
{
long expected_value = expected[expected_index];
+ int i;
for (i = 0; i < THREAD_COUNT; i++)
{
main ()
{
char buf[128];
- unsigned int i;
unsigned int n_big = 0;
initstate (time (NULL), buf, sizeof buf);
- for (i = 0; i < 1000; i++)
+ for (unsigned int i = 0; i < 1000; i++)
{
long r = random ();
ASSERT (0 <= r);
{
struct random_data rand_state;
char buf[128 + sizeof (int32_t)];
- unsigned int i;
unsigned int n_big = 0;
rand_state.state = NULL;
if (initstate_r (time (NULL), buf + alignment, sizeof buf - alignment,
&rand_state))
return 1;
- for (i = 0; i < 1000; i++)
+ for (unsigned int i = 0; i < 1000; i++)
{
int32_t r;
ASSERT (random_r (&rand_state, &r) == 0);
int
main ()
{
- int alignment;
- for (alignment = 0; alignment < sizeof (int32_t); alignment++)
+ for (int alignment = 0; alignment < sizeof (int32_t); alignment++)
if (test_failed (alignment))
return 1;
return test_exit_status;
ASSERT (rawmemchr (input, '\0') == input + n);
/* Alignment tests. */
- {
- int i, j;
- for (i = 0; i < 32; i++)
- {
- for (j = 0; j < 256; j++)
- input[i + j] = j;
- for (j = 0; j < 256; j++)
- {
- ASSERT (rawmemchr (input + i, j) == input + i + j);
- }
- }
- }
+ for (int i = 0; i < 32; i++)
+ {
+ for (int j = 0; j < 256; j++)
+ input[i + j] = j;
+ for (int j = 0; j < 256; j++)
+ {
+ ASSERT (rawmemchr (input + i, j) == input + i + j);
+ }
+ }
/* Ensure that no unaligned oversized reads occur. */
{
char *page_boundary = (char *) zerosize_ptr ();
- size_t i;
if (!page_boundary)
page_boundary = input + 4096;
memset (page_boundary - 512, '1', 511);
page_boundary[-1] = '2';
- for (i = 1; i <= 512; i++)
+ for (size_t i = 1; i <= 512; i++)
ASSERT (rawmemchr (page_boundary - i, (i * 0x01010100) | '2')
== page_boundary - 1);
}
static void
check_equals (gl_list_t list1, gl_list_t list2)
{
- size_t n, i;
+ size_t n;
n = gl_list_size (list1);
ASSERT (n == gl_list_size (list2));
- for (i = 0; i < n; i++)
+ for (size_t i = 0; i < n; i++)
{
ASSERT (gl_list_get_at (list1, i) == gl_list_get_at (list2, i));
}
size_t initial_size = RANDOM (50);
const void **contents =
(const void **) malloc (initial_size * sizeof (const void *));
- size_t i;
- unsigned int repeat;
- for (i = 0; i < initial_size; i++)
+ for (size_t i = 0; i < initial_size; i++)
contents[i] = RANDOM_OBJECT ();
/* Create list1. */
/* Create list2. */
list2 = gl_list_nx_create_empty (GL_RBTREE_LIST, NULL, NULL, NULL, true);
ASSERT (list2 != NULL);
- for (i = 0; i < initial_size; i++)
+ for (size_t i = 0; i < initial_size; i++)
ASSERT (gl_list_nx_add_last (list2, contents[i]) != NULL);
/* Create list3. */
check_equals_by_forward_iteration (list1, list2);
check_equals_by_backward_iteration (list1, list2);
- for (repeat = 0; repeat < 10000; repeat++)
+ for (unsigned int repeat = 0; repeat < 10000; repeat++)
{
unsigned int operation = RANDOM (18);
switch (operation)
iter1 = gl_list_iterator (list1);
iter2 = gl_list_iterator (list2);
iter3 = gl_list_iterator (list3);
- for (i = 0; i < n; i++)
+ for (size_t i = 0; i < n; i++)
{
ASSERT (gl_list_iterator_next (&iter1, &elt, NULL));
ASSERT (gl_list_get_at (list1, i) == elt);
iter1 = gl_list_iterator_from_to (list1, start, end);
iter2 = gl_list_iterator_from_to (list2, start, end);
iter3 = gl_list_iterator_from_to (list3, start, end);
- for (i = start; i < end; i++)
+ for (size_t i = start; i < end; i++)
{
ASSERT (gl_list_iterator_next (&iter1, &elt, NULL));
ASSERT (gl_list_get_at (list1, i) == elt);
const void *value1;
const void *key2;
const void *value2;
- size_t i;
iter1 = gl_omap_iterator (map1);
iter2 = gl_omap_iterator (map2);
- for (i = 0; i < n; i++)
+ for (size_t i = 0; i < n; i++)
{
ASSERT (gl_omap_iterator_next (&iter1, &key1, &value1));
ASSERT (gl_omap_iterator_next (&iter2, &key2, &value2));
{
size_t initial_size = RANDOM (20);
- size_t i;
- unsigned int repeat;
/* Create map1. */
map1 = gl_omap_nx_create_empty (GL_ARRAY_OMAP, (gl_mapkey_compar_fn) strcmp, NULL, NULL);
check_all (map1, map2);
/* Initialize them. */
- for (i = 0; i < initial_size; i++)
+ for (size_t i = 0; i < initial_size; i++)
{
const char *key = RANDOM_OBJECT ();
const char *value = RANDOM_OBJECT ();
check_all (map1, map2);
}
- for (repeat = 0; repeat < 100000; repeat++)
+ for (unsigned int repeat = 0; repeat < 100000; repeat++)
{
unsigned int operation = RANDOM (3);
switch (operation)
gl_oset_iterator_t iter1, iter2;
const void *elt1;
const void *elt2;
- size_t i;
iter1 = gl_oset_iterator (set1);
iter2 = gl_oset_iterator (set2);
- for (i = 0; i < n; i++)
+ for (size_t i = 0; i < n; i++)
{
ASSERT (gl_oset_iterator_next (&iter1, &elt1));
ASSERT (gl_oset_iterator_next (&iter2, &elt2));
{
size_t initial_size = RANDOM (20);
- size_t i;
- unsigned int repeat;
/* Create set1. */
set1 = gl_oset_nx_create_empty (GL_ARRAY_OSET, (gl_setelement_compar_fn) strcmp, NULL);
check_all (set1, set2);
/* Initialize them. */
- for (i = 0; i < initial_size; i++)
+ for (size_t i = 0; i < initial_size; i++)
{
const char *obj = RANDOM_OBJECT ();
ASSERT (gl_oset_nx_add (set1, obj) == gl_oset_nx_add (set2, obj));
check_all (set1, set2);
}
- for (repeat = 0; repeat < 100000; repeat++)
+ for (unsigned int repeat = 0; repeat < 100000; repeat++)
{
unsigned int operation = RANDOM (4);
switch (operation)
static void
check_equals (gl_list_t list1, gl_list_t list2)
{
- size_t n, i;
+ size_t n;
n = gl_list_size (list1);
ASSERT (n == gl_list_size (list2));
- for (i = 0; i < n; i++)
+ for (size_t i = 0; i < n; i++)
{
ASSERT (gl_list_get_at (list1, i) == gl_list_get_at (list2, i));
}
size_t initial_size = RANDOM (50);
const void **contents =
(const void **) malloc (initial_size * sizeof (const void *));
- size_t i;
- unsigned int repeat;
- for (i = 0; i < initial_size; i++)
+ for (size_t i = 0; i < initial_size; i++)
contents[i] = RANDOM_OBJECT ();
/* Create list1. */
list2 = gl_list_nx_create_empty (GL_RBTREEHASH_LIST,
string_equals, string_hash, NULL, true);
ASSERT (list2 != NULL);
- for (i = 0; i < initial_size; i++)
+ for (size_t i = 0; i < initial_size; i++)
ASSERT (gl_list_nx_add_last (list2, contents[i]) != NULL);
/* Create list3. */
check_equals_by_forward_iteration (list1, list2);
check_equals_by_backward_iteration (list1, list2);
- for (repeat = 0; repeat < 10000; repeat++)
+ for (unsigned int repeat = 0; repeat < 10000; repeat++)
{
unsigned int operation = RANDOM (18);
switch (operation)
iter1 = gl_list_iterator (list1);
iter2 = gl_list_iterator (list2);
iter3 = gl_list_iterator (list3);
- for (i = 0; i < n; i++)
+ for (size_t i = 0; i < n; i++)
{
ASSERT (gl_list_iterator_next (&iter1, &elt, NULL));
ASSERT (gl_list_get_at (list1, i) == elt);
iter1 = gl_list_iterator_from_to (list1, start, end);
iter2 = gl_list_iterator_from_to (list2, start, end);
iter3 = gl_list_iterator_from_to (list3, start, end);
- for (i = start; i < end; i++)
+ for (size_t i = start; i < end; i++)
{
ASSERT (gl_list_iterator_next (&iter1, &elt, NULL));
ASSERT (gl_list_get_at (list1, i) == elt);
ASSERT (errno == ENOTDIR || errno == EINVAL); /* AIX yields EINVAL */
ASSERT (unlink (BASE "file") == 0);
ASSERT (unlink (BASE "link2") == 0);
- {
- /* Up till now, no readlink has been successful, so buf should be
- unchanged. */
- int i;
- for (i = 0; i < sizeof buf; i++)
- ASSERT (buf[i] == (char) 0xff);
- }
+ /* Up till now, no readlink has been successful, so buf should be
+ unchanged. */
+ for (int i = 0; i < sizeof buf; i++)
+ ASSERT (buf[i] == (char) 0xff);
{
size_t len = strlen (BASE "dir");
/* When passing too small of a buffer, expect the truncated
XNMALLOC (num_entries, STRUCT_UTMP));
idx_t boot_time_count = 0;
- idx_t i;
- for (i = 0; i < num_entries; i++)
+ for (idx_t i = 0; i < num_entries; i++)
{
const STRUCT_UTMP *entry = &entries[i];
{
regex_t re;
regmatch_t rm[5];
- size_t i;
- int n;
- for (i = 0; i < sizeof (tests) / sizeof (tests[0]); ++i)
+ for (size_t i = 0; i < sizeof (tests) / sizeof (tests[0]); ++i)
{
- n = regcomp (&re, tests[i].pattern, tests[i].flags);
- if (n != 0)
+ int err = regcomp (&re, tests[i].pattern, tests[i].flags);
+ if (err != 0)
{
char buf[500];
- regerror (n, &re, buf, sizeof (buf));
+ regerror (err, &re, buf, sizeof (buf));
report_error ("%s: regcomp %zd failed: %s", tests[i].pattern, i, buf);
continue;
}
continue;
}
- for (n = 0; n < tests[i].nmatch; ++n)
+ for (int n = 0; n < tests[i].nmatch; ++n)
if (rm[n].rm_so != tests[i].rm[n].rm_so
|| rm[n].rm_eo != tests[i].rm[n].rm_eo)
{
{
static struct re_pattern_buffer regex;
unsigned char folded_chars[UCHAR_MAX + 1];
- int i;
const char *s;
struct re_registers regs;
else
{
memset (®s, 0, sizeof regs);
- i = re_search (®ex, data, sizeof data - 1,
- 0, sizeof data - 1, ®s);
- if (i != -1)
+ int ret = re_search (®ex, data, sizeof data - 1,
+ 0, sizeof data - 1, ®s);
+ if (ret != -1)
report_error ("re_search '%s' on '%s' returned %d",
- pat, data, i);
+ pat, data, ret);
regfree (®ex);
free (regs.start);
free (regs.end);
else
{
memset (®s, 0, sizeof regs);
- i = re_search (®ex, data, sizeof data - 1,
- 0, sizeof data - 1, NULL);
- if (i != 0 && i != 21)
+ int ret = re_search (®ex, data, sizeof data - 1,
+ 0, sizeof data - 1, NULL);
+ if (ret != 0 && ret != 21)
report_error ("re_search '%s' on '%s' returned %d",
- pat, data, i);
+ pat, data, ret);
regfree (®ex);
free (regs.start);
free (regs.end);
static char const data[] = "\xc4\xb0";
memset (®s, 0, sizeof regs);
- i = re_search (®ex, data, sizeof data - 1, 0, sizeof data - 1,
- ®s);
- if (i != 0)
+ int ret =
+ re_search (®ex, data, sizeof data - 1, 0, sizeof data - 1,
+ ®s);
+ if (ret != 0)
report_error ("re_search '%s' on '%s' returned %d",
- pat, data, i);
+ pat, data, ret);
regfree (®ex);
free (regs.start);
free (regs.end);
/* This should fail, but succeeds for glibc-2.5. */
memset (®s, 0, sizeof regs);
static char const data[] = "a\nb";
- i = re_search (®ex, data, sizeof data - 1, 0, sizeof data - 1, ®s);
- if (i != -1)
+ int ret =
+ re_search (®ex, data, sizeof data - 1, 0, sizeof data - 1, ®s);
+ if (ret != -1)
report_error ("re_search '%s' on '%s' returned %d",
- pat_3957, data, i);
+ pat_3957, data, ret);
regfree (®ex);
free (regs.start);
free (regs.end);
in grep-2.3. */
re_set_syntax (RE_SYNTAX_POSIX_EGREP);
memset (®ex, 0, sizeof regex);
- for (i = 0; i <= UCHAR_MAX; i++)
+ for (int i = 0; i <= UCHAR_MAX; i++)
folded_chars[i] = i;
regex.translate = folded_chars;
static char const pat75[] = "a[[:@:>@:]]b\n";
{
memset (®s, 0, sizeof regs);
static char const data[] = "an";
- i = re_match (®ex, data, sizeof data - 1, 0, ®s);
- if (i != 2)
+ int ret = re_match (®ex, data, sizeof data - 1, 0, ®s);
+ if (ret != 2)
report_error ("re_match '%s' on '%s' at 2 returned %d",
- pat_stolfi, data, i);
+ pat_stolfi, data, ret);
regfree (®ex);
free (regs.start);
free (regs.end);
{
memset (®s, 0, sizeof regs);
static char const data[] = "wxy";
- i = re_search (®ex, data, sizeof data - 1, 2, -2, ®s);
- if (i != 1)
- report_error ("re_search '%s' on '%s' returned %d", pat_x, data, i);
+ int ret = re_search (®ex, data, sizeof data - 1, 2, -2, ®s);
+ if (ret != 1)
+ report_error ("re_search '%s' on '%s' returned %d", pat_x, data, ret);
regfree (®ex);
free (regs.start);
free (regs.end);
{
memset (®s, 0, sizeof regs);
static char const data[] = "WXY";
- i = re_search (®ex, data, sizeof data - 1, 0, 3, ®s);
- if (i < 0)
- report_error ("re_search '%s' on '%s' returned %d", pat_x, data, i);
+ int ret = re_search (®ex, data, sizeof data - 1, 0, 3, ®s);
+ if (ret < 0)
+ report_error ("re_search '%s' on '%s' returned %d", pat_x, data, ret);
regfree (®ex);
free (regs.start);
free (regs.end);
memset (®s, 0, sizeof regs);
static char const data[] = "a";
int datalen = sizeof data - 1;
- i = re_search (®ex, data, datalen, 0, datalen, ®s);
- if (i != 0)
- report_error ("re_search '%s' on '%s' returned %d", pat_sub2, data, i);
+ int ret = re_search (®ex, data, datalen, 0, datalen, ®s);
+ if (ret != 0)
+ report_error ("re_search '%s' on '%s' returned %d",
+ pat_sub2, data, ret);
else if (regs.num_regs < 2)
report_error ("re_search '%s' on '%s' returned only %d registers",
pat_sub2, data, (int) regs.num_regs);
static void
test_function (void)
{
- int i;
- int j;
const DOUBLE TWO_MANT_DIG =
/* Assume MANT_DIG <= 5 * 31.
Use the identity
* (DOUBLE) (1U << ((MANT_DIG - 1 + 4) / 5));
/* Randomized tests. */
- for (i = 0; i < SIZEOF (RANDOM) / 5; i++)
- for (j = 0; j < SIZEOF (RANDOM) / 5; j++)
+ for (int i = 0; i < SIZEOF (RANDOM) / 5; i++)
+ for (int j = 0; j < SIZEOF (RANDOM) / 5; j++)
{
DOUBLE x = L_(16.0) * RANDOM[i]; /* 0.0 <= x <= 16.0 */
DOUBLE y = RANDOM[j]; /* 0.0 <= y < 1.0 */
}
}
- for (i = 0; i < SIZEOF (RANDOM) / 5; i++)
- for (j = 0; j < SIZEOF (RANDOM) / 5; j++)
+ for (int i = 0; i < SIZEOF (RANDOM) / 5; i++)
+ for (int j = 0; j < SIZEOF (RANDOM) / 5; j++)
{
DOUBLE x = L_(1.0e9) * RANDOM[i]; /* 0.0 <= x <= 10^9 */
DOUBLE y = RANDOM[j]; /* 0.0 <= y < 1.0 */
{
int large_exp = (MAX_EXP - 1 < 1000 ? MAX_EXP - 1 : 1000);
DOUBLE large = my_ldexp (L_(1.0), large_exp); /* = 2^large_exp */
- for (i = 0; i < SIZEOF (RANDOM) / 10; i++)
- for (j = 0; j < SIZEOF (RANDOM) / 10; j++)
+ for (int i = 0; i < SIZEOF (RANDOM) / 10; i++)
+ for (int j = 0; j < SIZEOF (RANDOM) / 10; j++)
{
DOUBLE x = large * RANDOM[i]; /* 0.0 <= x <= 2^large_exp */
DOUBLE y = RANDOM[j]; /* 0.0 <= y < 1.0 */
int
main (void)
{
- int i;
int dfd;
char *cwd;
int result;
last scenario (two relative paths given, neither one AT_FDCWD)
has two paths, based on whether the two fds are equivalent, so we
do the other variant after the loop. */
- for (i = 0; i < 16; i++)
+ for (int i = 0; i < 16; i++)
{
int fd1 = (i & 8) ? dfd : AT_FDCWD;
char *file1 = file_name_concat ((i & 4) ? ".." : cwd, BASE "xx", NULL);
int
main (void)
{
- int i;
int dfd;
char *cwd;
int result;
last scenario (two relative paths given, neither one AT_FDCWD)
has two paths, based on whether the two fds are equivalent, so we
do the other variant after the loop. */
- for (i = 0; i < 16; i++)
+ for (int i = 0; i < 16; i++)
{
int fd1 = (i & 8) ? dfd : AT_FDCWD;
char *file1 = file_name_concat ((i & 4) ? ".." : cwd, BASE "xx", NULL);
"\x00\x00\x00\x00\x00\x00\x00\x00";
char ct[] = "\xC3\x4C\x05\x2C\xC0\xDA\x8D\x73"
"\x45\x1A\xFE\x5F\x03\xBE\x29\x7F";
- size_t round;
rc = rijndaelMakeKey (&key, RIJNDAEL_DIR_ENCRYPT,
128, "00000000000000000000000000000000");
memset (in, 0, RIJNDAEL_BITSPERBLOCK / 8);
- for (round = 0; round < 10000; round++)
+ for (size_t round = 0; round < 10000; round++)
{
rc = rijndaelBlockEncrypt (&cipher, &key, in, 128, out);
if (rc < 0)
if (memcmp (out, ct, RIJNDAEL_BITSPERBLOCK / 8) != 0)
{
- size_t i;
printf ("expected:\n");
- for (i = 0; i < RIJNDAEL_BITSPERBLOCK / 8; i++)
+ for (size_t i = 0; i < RIJNDAEL_BITSPERBLOCK / 8; i++)
printf ("%02x ", ct[i] & 0xFF);
printf ("\ncomputed:\n");
- for (i = 0; i < RIJNDAEL_BITSPERBLOCK / 8; i++)
+ for (size_t i = 0; i < RIJNDAEL_BITSPERBLOCK / 8; i++)
printf ("%02x ", out[i] & 0xFF);
printf ("\n");
return 1;
if (rc != 0)
printf ("cipherInit failed %d\n", rc);
- for (round = 0; round < 10000; round++)
+ for (size_t round = 0; round < 10000; round++)
{
memcpy (in, out, RIJNDAEL_BITSPERBLOCK / 8);
if (memcmp (out, pt, RIJNDAEL_BITSPERBLOCK / 8) != 0)
{
- size_t i;
printf ("expected:\n");
- for (i = 0; i < RIJNDAEL_BITSPERBLOCK / 8; i++)
+ for (size_t i = 0; i < RIJNDAEL_BITSPERBLOCK / 8; i++)
printf ("%02x ", pt[i] & 0xFF);
printf ("\ncomputed:\n");
- for (i = 0; i < RIJNDAEL_BITSPERBLOCK / 8; i++)
+ for (size_t i = 0; i < RIJNDAEL_BITSPERBLOCK / 8; i++)
printf ("%02x ", out[i] & 0xFF);
printf ("\n");
return 1;
ASSERT (ISNAN (RINT (NAN)));
/* Randomized tests. */
- {
- int i;
-
- for (i = 0; i < SIZEOF (RANDOM); i++)
- {
- DOUBLE x;
-
- x = L_(0.5) * RANDOM[i];
- ASSERT (RINT (x) == L_(0.0));
- x = - x;
- ASSERT (RINT (x) == L_(0.0));
-
- x = L_(1.0) - L_(0.5) * RANDOM[i];
- ASSERT (RINT (x) == L_(1.0));
- x = - x;
- ASSERT (RINT (x) == - L_(1.0));
-
- x = L_(1.0) + L_(0.5) * RANDOM[i];
- ASSERT (RINT (x) == L_(1.0));
- x = - x;
- ASSERT (RINT (x) == - L_(1.0));
-
- x = L_(2.0) - L_(0.5) * RANDOM[i];
- ASSERT (RINT (x) == L_(2.0));
- x = - x;
- ASSERT (RINT (x) == - L_(2.0));
- }
- }
+ for (int i = 0; i < SIZEOF (RANDOM); i++)
+ {
+ DOUBLE x;
+
+ x = L_(0.5) * RANDOM[i];
+ ASSERT (RINT (x) == L_(0.0));
+ x = - x;
+ ASSERT (RINT (x) == L_(0.0));
+
+ x = L_(1.0) - L_(0.5) * RANDOM[i];
+ ASSERT (RINT (x) == L_(1.0));
+ x = - x;
+ ASSERT (RINT (x) == - L_(1.0));
+
+ x = L_(1.0) + L_(0.5) * RANDOM[i];
+ ASSERT (RINT (x) == L_(1.0));
+ x = - x;
+ ASSERT (RINT (x) == - L_(1.0));
+
+ x = L_(2.0) - L_(0.5) * RANDOM[i];
+ ASSERT (RINT (x) == L_(2.0));
+ x = - x;
+ ASSERT (RINT (x) == - L_(2.0));
+ }
}
int
main (void)
{
- DOUBLE_UINT highbits, lowbits;
int error = 0;
- for (highbits = 0; highbits < (1 << NUM_HIGHBITS); highbits++)
- for (lowbits = 0; lowbits < (1 << NUM_LOWBITS); lowbits++)
+ for (DOUBLE_UINT highbits = 0; highbits < (1 << NUM_HIGHBITS); highbits++)
+ for (DOUBLE_UINT lowbits = 0; lowbits < (1 << NUM_LOWBITS); lowbits++)
{
/* Combine highbits and lowbits into a floating-point number,
sign-extending the lowbits to DOUBLE_BITS-NUM_HIGHBITS bits. */
, ACL_TYPE_EXTENDED
# endif
};
- int t;
- for (t = 0; t < sizeof (types) / sizeof (types[0]); t++)
+ for (int t = 0; t < sizeof (types) / sizeof (types[0]); t++)
{
int type = types[t];
acl_t acl1;
{
aclent_t *entries1 = XNMALLOC (count1, aclent_t);
aclent_t *entries2 = XNMALLOC (count2, aclent_t);
- int i;
if (count1 > 0 && acl (file1, GETACL, count1, entries1) < count1)
{
fflush (stderr);
abort ();
}
- for (i = 0; i < count1; i++)
+ for (int i = 0; i < count1; i++)
{
if (entries1[i].a_type != entries2[i].a_type)
{
ace_t *entries1 = XNMALLOC (count1, ace_t);
ace_t *entries2 = XNMALLOC (count2, ace_t);
int ret;
- int i;
ret = acl (file1, ACE_GETACL, count1, entries1);
if (ret < 0 && errno == EINVAL)
return 1;
}
- for (i = 0; i < count1; i++)
+ for (int i = 0; i < count1; i++)
{
if (entries1[i].a_type != entries2[i].a_type)
{
{
struct acl_entry *entries1 = XNMALLOC (count1, struct acl_entry);
struct acl_entry *entries2 = XNMALLOC (count2, struct acl_entry);
- int i;
if (getacl (file1, count1, entries1) < count1)
{
fflush (stderr);
abort ();
}
- for (i = 0; i < count1; i++)
+ for (int i = 0; i < count1; i++)
{
if (entries1[i].uid != entries2[i].uid)
{
{
struct acl *entries1 = XNMALLOC (count1, struct acl);
struct acl *entries2 = XNMALLOC (count2, struct acl);
- int i;
if (acl ((char *) file1, ACL_GET, count1, entries1) < count1)
{
fflush (stderr);
abort ();
}
- for (i = 0; i < count1; i++)
+ for (int i = 0; i < count1; i++)
{
if (entries1[i].a_type != entries2[i].a_type)
{
{
struct acl *entries1 = XNMALLOC (count1, struct acl);
struct acl *entries2 = XNMALLOC (count2, struct acl);
- int i;
if (acl ((char *) file1, ACL_GET, count1, entries1) < count1)
{
fflush (stderr);
abort ();
}
- for (i = 0; i < count1; i++)
+ for (int i = 0; i < count1; i++)
{
if (entries1[i].a_type != entries2[i].a_type)
{
/* Check scratch_buffer_set_array_size. */
{
size_t sizes[] = { 100, 1000, 10000, 100000 };
- size_t s;
- for (s = 0; s < SIZEOF (sizes); s++)
+ for (size_t s = 0; s < SIZEOF (sizes); s++)
{
size_t size = sizes[s];
struct scratch_buffer buf;
bool ok;
- size_t i;
scratch_buffer_init (&buf);
ok = scratch_buffer_set_array_size (&buf, size, 1);
ASSERT (ok);
- for (i = 0; i < size; i++)
+ for (size_t i = 0; i < size; i++)
((unsigned char *) buf.data)[i] = byte_at (i);
memset (buf.data, 'x', buf.length);
/* Check scratch_buffer_grow. */
{
size_t sizes[] = { 100, 1000, 10000, 100000 };
- size_t s;
- for (s = 0; s < SIZEOF (sizes); s++)
+ for (size_t s = 0; s < SIZEOF (sizes); s++)
{
size_t size = sizes[s];
struct scratch_buffer buf;
bool ok;
- size_t i;
scratch_buffer_init (&buf);
ASSERT (ok);
}
- for (i = 0; i < size; i++)
+ for (size_t i = 0; i < size; i++)
((unsigned char *) buf.data)[i] = byte_at (i);
memset (buf.data, 'x', buf.length);
size_t s;
size_t size;
bool ok;
- size_t i;
scratch_buffer_init (&buf);
ok = scratch_buffer_set_array_size (&buf, size, 1);
ASSERT (ok);
- for (i = 0; i < size; i++)
+ for (size_t i = 0; i < size; i++)
((unsigned char *) buf.data)[i] = byte_at (i);
for (; s < SIZEOF (sizes); s++)
ASSERT (ok);
}
- for (i = 0; i < oldsize; i++)
+ for (size_t i = 0; i < oldsize; i++)
ASSERT(((unsigned char *) buf.data)[i] == byte_at (i));
- for (i = oldsize; i < size; i++)
+ for (size_t i = oldsize; i < size; i++)
((unsigned char *) buf.data)[i] = byte_at (i);
}
{
char origname[HOST_NAME_MAX];
char newname[HOST_NAME_MAX];
- int rcs, i;
+ int rcs;
/* skip the tests if we don't have root privilege. this does not
consider things like CAP_SYS_ADMIN (linux) or PRIV_SYS_ADMIN
#if !(defined __CYGWIN__ || defined __HAIKU__)
{
char longname[HOST_NAME_MAX + 2];
+ int i;
/* glibc does allow setting a zero length name, so the lower bound
needs no test. validate that we are constrained by
{
/* Check the shell_quote_length, shell_quote_copy, shell_quote functions. */
{
- int c;
-
/* Empty argument. */
check_one ("", "''");
check_one ("foo'bar\"baz", "'foo'\\''bar\"baz'"); /* or "\"foo'bar\\\"baz\"" */
/* All other characters don't need quoting. */
- for (c = 1; c <= UCHAR_MAX; c++)
+ for (int c = 1; c <= UCHAR_MAX; c++)
if (strchr ("\t\n\r !\"#$&'()*;<=>?^[\\]`{|}~", c) == NULL)
{
char s[5];
if (memcmp (sha1_buffer (in1, strlen (in1), buf),
out1, SHA1_DIGEST_SIZE) != 0)
{
- size_t i;
printf ("expected:\n");
- for (i = 0; i < SHA1_DIGEST_SIZE; i++)
+ for (size_t i = 0; i < SHA1_DIGEST_SIZE; i++)
printf ("%02x ", out1[i] & 0xFFu);
printf ("\ncomputed:\n");
- for (i = 0; i < SHA1_DIGEST_SIZE; i++)
+ for (size_t i = 0; i < SHA1_DIGEST_SIZE; i++)
printf ("%02x ", buf[i] & 0xFFu);
printf ("\n");
return 1;
if (memcmp (sha224_buffer (in1, strlen (in1), buf),
out1, SHA224_DIGEST_SIZE) != 0)
{
- size_t i;
printf ("expected:\n");
- for (i = 0; i < SHA224_DIGEST_SIZE; i++)
+ for (size_t i = 0; i < SHA224_DIGEST_SIZE; i++)
printf ("%02x ", out1[i] & 0xFFu);
printf ("\ncomputed:\n");
- for (i = 0; i < SHA224_DIGEST_SIZE; i++)
+ for (size_t i = 0; i < SHA224_DIGEST_SIZE; i++)
printf ("%02x ", buf[i] & 0xFFu);
printf ("\n");
return 1;
if (memcmp (sha256_buffer (in1, strlen (in1), buf),
out1, SHA256_DIGEST_SIZE) != 0)
{
- size_t i;
printf ("expected:\n");
- for (i = 0; i < SHA256_DIGEST_SIZE; i++)
+ for (size_t i = 0; i < SHA256_DIGEST_SIZE; i++)
printf ("%02x ", out1[i] & 0xFFu);
printf ("\ncomputed:\n");
- for (i = 0; i < SHA256_DIGEST_SIZE; i++)
+ for (size_t i = 0; i < SHA256_DIGEST_SIZE; i++)
printf ("%02x ", buf[i] & 0xFFu);
printf ("\n");
return 1;
if (memcmp (sha3_224_buffer (message, len, buf),
expect, SHA3_224_DIGEST_SIZE) != 0)
{
- size_t i;
printf ("expected:\n");
- for (i = 0; i < SHA3_224_DIGEST_SIZE; i++)
+ for (size_t i = 0; i < SHA3_224_DIGEST_SIZE; i++)
printf ("%02x ", expect[i] & 0xFFu);
printf ("\ncomputed:\n");
- for (i = 0; i < SHA3_224_DIGEST_SIZE; i++)
+ for (size_t i = 0; i < SHA3_224_DIGEST_SIZE; i++)
printf ("%02x ", buf[i] & 0xFFu);
printf ("\n");
return 1;
if (memcmp (sha3_256_buffer (message, len, buf),
expect, SHA3_256_DIGEST_SIZE) != 0)
{
- size_t i;
printf ("expected:\n");
- for (i = 0; i < SHA3_256_DIGEST_SIZE; i++)
+ for (size_t i = 0; i < SHA3_256_DIGEST_SIZE; i++)
printf ("%02x ", expect[i] & 0xFFu);
printf ("\ncomputed:\n");
- for (i = 0; i < SHA3_256_DIGEST_SIZE; i++)
+ for (size_t i = 0; i < SHA3_256_DIGEST_SIZE; i++)
printf ("%02x ", buf[i] & 0xFFu);
printf ("\n");
return 1;
if (memcmp (sha3_384_buffer (message, len, buf),
expect, SHA3_384_DIGEST_SIZE) != 0)
{
- size_t i;
printf ("expected:\n");
- for (i = 0; i < SHA3_384_DIGEST_SIZE; i++)
+ for (size_t i = 0; i < SHA3_384_DIGEST_SIZE; i++)
printf ("%02x ", expect[i] & 0xFFu);
printf ("\ncomputed:\n");
- for (i = 0; i < SHA3_384_DIGEST_SIZE; i++)
+ for (size_t i = 0; i < SHA3_384_DIGEST_SIZE; i++)
printf ("%02x ", buf[i] & 0xFFu);
printf ("\n");
return 1;
if (memcmp (sha3_512_buffer (message, len, buf),
expect, SHA3_512_DIGEST_SIZE) != 0)
{
- size_t i;
printf ("expected:\n");
- for (i = 0; i < SHA3_512_DIGEST_SIZE; i++)
+ for (size_t i = 0; i < SHA3_512_DIGEST_SIZE; i++)
printf ("%02x ", expect[i] & 0xFFu);
printf ("\ncomputed:\n");
- for (i = 0; i < SHA3_512_DIGEST_SIZE; i++)
+ for (size_t i = 0; i < SHA3_512_DIGEST_SIZE; i++)
printf ("%02x ", buf[i] & 0xFFu);
printf ("\n");
return 1;
if (memcmp (sha384_buffer (in1, strlen (in1), buf),
out1, SHA384_DIGEST_SIZE) != 0)
{
- size_t i;
printf ("expected:\n");
- for (i = 0; i < SHA384_DIGEST_SIZE; i++)
+ for (size_t i = 0; i < SHA384_DIGEST_SIZE; i++)
printf ("%02x ", out1[i] & 0xFFu);
printf ("\ncomputed:\n");
- for (i = 0; i < SHA384_DIGEST_SIZE; i++)
+ for (size_t i = 0; i < SHA384_DIGEST_SIZE; i++)
printf ("%02x ", buf[i] & 0xFFu);
printf ("\n");
return 1;
if (memcmp (sha512_buffer (in1, strlen (in1), buf),
out1, SHA512_DIGEST_SIZE) != 0)
{
- size_t i;
printf ("expected:\n");
- for (i = 0; i < SHA512_DIGEST_SIZE; i++)
+ for (size_t i = 0; i < SHA512_DIGEST_SIZE; i++)
printf ("%02x ", out1[i] & 0xFFu);
printf ("\ncomputed:\n");
- for (i = 0; i < SHA512_DIGEST_SIZE; i++)
+ for (size_t i = 0; i < SHA512_DIGEST_SIZE; i++)
printf ("%02x ", buf[i] & 0xFFu);
printf ("\n");
return 1;
int_mutator_thread (void *arg)
{
int *pcounter = (int *) arg;
- int repeat;
- for (repeat = REPEAT_COUNT; repeat > 0; repeat--)
+ for (int repeat = REPEAT_COUNT; repeat > 0; repeat--)
{
if (atomic_compare_and_swap (&int_variable, 0, 10) == 0)
pcounter[0]++;
ptr_mutator_thread (void *arg)
{
int *pcounter = (int *) arg;
- int repeat;
- for (repeat = REPEAT_COUNT; repeat > 0; repeat--)
+ for (int repeat = REPEAT_COUNT; repeat > 0; repeat--)
{
if (atomic_compare_and_swap_ptr (&ptr_variable, 0, 10) == 0)
pcounter[0]++;
/* Check atomicity of atomic_compare_and_swap. */
{
void * (*funcs[2]) (void *) = { int_mutator_thread, ptr_mutator_thread };
- int f;
- for (f = 0; f < 2; f++)
+ for (int f = 0; f < 2; f++)
{
void * (*func) (void *) = funcs[f];
- int i, j;
gl_thread_t threads[THREAD_COUNT];
/* Initialization. */
- for (i = 0; i < THREAD_COUNT; i++)
- for (j = 0; j < 5; j++)
+ for (int i = 0; i < THREAD_COUNT; i++)
+ for (int j = 0; j < 5; j++)
counter[i][j] = 0;
/* Spawn the threads. */
- for (i = 0; i < THREAD_COUNT; i++)
+ for (int i = 0; i < THREAD_COUNT; i++)
threads[i] = gl_thread_create (func, &counter[i][0]);
/* Wait for the threads to terminate. */
- for (i = 0; i < THREAD_COUNT; i++)
+ for (int i = 0; i < THREAD_COUNT; i++)
gl_thread_join (threads[i], NULL);
/* Sum up the work that the threads have done. */
unsigned int sum[5];
- for (j = 0; j < 5; j++)
+ for (int j = 0; j < 5; j++)
{
sum[j] = 0;
- for (i = 0; i < THREAD_COUNT; i++)
+ for (int i = 0; i < THREAD_COUNT; i++)
sum[j] += counter[i][j];
}
if (memcmp (sm3_buffer (in, strlen (in), buf),
out, SM3_DIGEST_SIZE) != 0)
{
- size_t i;
printf ("expected:\n");
- for (i = 0; i < SM3_DIGEST_SIZE; i++)
+ for (size_t i = 0; i < SM3_DIGEST_SIZE; i++)
printf ("%02x ", out[i] & 0xFFu);
printf ("\ncomputed:\n");
- for (i = 0; i < SM3_DIGEST_SIZE; i++)
+ for (size_t i = 0; i < SM3_DIGEST_SIZE; i++)
printf ("%02x ", buf[i] & 0xFFu);
printf ("\n");
return 1;
"\xde\xbe\x9f\xf9\x22\x75\xb8\xa1\x38\x60\x48\x89\xc1\x8e\x5a\x4d"
"\x6f\xdb\x70\xe5\x38\x7e\x57\x65\x29\x3d\xcb\xa3\x9c\x0c\x57\x32",
};
- size_t i;
- for (i = 0; i < sizeof (in) / sizeof (in[0]); i++)
+ for (size_t i = 0; i < sizeof (in) / sizeof (in[0]); i++)
{
if (test (in[i], out[i]))
return 1;
test_function (int (*my_snprintf) (char *, size_t, const char *, ...))
{
char buf[8];
- int size;
char result[5000];
/* Test return value convention. */
- for (size = 0; size <= 8; size++)
+ for (int size = 0; size <= 8; size++)
{
int retval;
{ 1.234321234321234e35, "123432123432123*********************.000000" },
{ 1.234321234321234e36, "123432123432123**********************.000000" }
};
- size_t k;
- for (k = 0; k < SIZEOF (data); k++)
+ for (size_t k = 0; k < SIZEOF (data); k++)
{
int retval =
my_snprintf (result, sizeof (result), "%f", data[k].value);
{ 1.234321234321234e35L, "123432123432123*********************.000000" },
{ 1.234321234321234e36L, "123432123432123**********************.000000" }
};
- size_t k;
- for (k = 0; k < SIZEOF (data); k++)
+ for (size_t k = 0; k < SIZEOF (data); k++)
{
int retval =
my_snprintf (result, sizeof (result), "%Lf", data[k].value);
{ 1.234321234321234e35, "1.234321e+35" },
{ 1.234321234321234e36, "1.234321e+36" }
};
- size_t k;
- for (k = 0; k < SIZEOF (data); k++)
+ for (size_t k = 0; k < SIZEOF (data); k++)
{
int retval =
my_snprintf (result, sizeof (result), "%e", data[k].value);
{ 1.234321234321234e35L, "1.234321e+35" },
{ 1.234321234321234e36L, "1.234321e+36" }
};
- size_t k;
- for (k = 0; k < SIZEOF (data); k++)
+ for (size_t k = 0; k < SIZEOF (data); k++)
{
int retval =
my_snprintf (result, sizeof (result), "%Le", data[k].value);
{ 1.234321234321234e35, "1.23432e+35" },
{ 1.234321234321234e36, "1.23432e+36" }
};
- size_t k;
- for (k = 0; k < SIZEOF (data); k++)
+ for (size_t k = 0; k < SIZEOF (data); k++)
{
int retval =
my_snprintf (result, sizeof (result), "%g", data[k].value);
{ 1.234321234321234e35L, "1.23432e+35" },
{ 1.234321234321234e36L, "1.23432e+36" }
};
- size_t k;
- for (k = 0; k < SIZEOF (data); k++)
+ for (size_t k = 0; k < SIZEOF (data); k++)
{
int retval =
my_snprintf (result, sizeof (result), "%Lg", data[k].value);
{
int retval =
my_snprintf (result, sizeof (result), "%.4000d %d", 1234567, 99);
- size_t i;
- for (i = 0; i < 4000 - 7; i++)
+ for (size_t i = 0; i < 4000 - 7; i++)
ASSERT (result[i] == '0');
ASSERT (strcmp (result + 4000 - 7, "1234567 99") == 0);
ASSERT (retval == strlen (result));
{
int retval =
my_snprintf (result, sizeof (result), "%.*d %d", 4000, 1234567, 99);
- size_t i;
- for (i = 0; i < 4000 - 7; i++)
+ for (size_t i = 0; i < 4000 - 7; i++)
ASSERT (result[i] == '0');
ASSERT (strcmp (result + 4000 - 7, "1234567 99") == 0);
ASSERT (retval == strlen (result));
{
int retval =
my_snprintf (result, sizeof (result), "%.4000d %d", -1234567, 99);
- size_t i;
ASSERT (result[0] == '-');
- for (i = 0; i < 4000 - 7; i++)
+ for (size_t i = 0; i < 4000 - 7; i++)
ASSERT (result[1 + i] == '0');
ASSERT (strcmp (result + 1 + 4000 - 7, "1234567 99") == 0);
ASSERT (retval == strlen (result));
{
int retval =
my_snprintf (result, sizeof (result), "%.4000u %d", 1234567, 99);
- size_t i;
- for (i = 0; i < 4000 - 7; i++)
+ for (size_t i = 0; i < 4000 - 7; i++)
ASSERT (result[i] == '0');
ASSERT (strcmp (result + 4000 - 7, "1234567 99") == 0);
ASSERT (retval == strlen (result));
{
int retval =
my_snprintf (result, sizeof (result), "%.4000o %d", 1234567, 99);
- size_t i;
- for (i = 0; i < 4000 - 7; i++)
+ for (size_t i = 0; i < 4000 - 7; i++)
ASSERT (result[i] == '0');
ASSERT (strcmp (result + 4000 - 7, "4553207 99") == 0);
ASSERT (retval == strlen (result));
{
int retval =
my_snprintf (result, sizeof (result), "%.4000x %d", 1234567, 99);
- size_t i;
- for (i = 0; i < 4000 - 6; i++)
+ for (size_t i = 0; i < 4000 - 6; i++)
ASSERT (result[i] == '0');
ASSERT (strcmp (result + 4000 - 6, "12d687 99") == 0);
ASSERT (retval == strlen (result));
{
int retval =
my_snprintf (result, sizeof (result), "%#.4000x %d", 1234567, 99);
- size_t i;
ASSERT (result[0] == '0');
ASSERT (result[1] == 'x');
- for (i = 0; i < 4000 - 6; i++)
+ for (size_t i = 0; i < 4000 - 6; i++)
ASSERT (result[2 + i] == '0');
ASSERT (strcmp (result + 2 + 4000 - 6, "12d687 99") == 0);
ASSERT (retval == strlen (result));
{
int retval =
my_snprintf (result, sizeof (result), "%.4000f %d", 1.0, 99);
- size_t i;
ASSERT (result[0] == '1');
ASSERT (result[1] == '.');
- for (i = 0; i < 4000; i++)
+ for (size_t i = 0; i < 4000; i++)
ASSERT (result[2 + i] == '0');
ASSERT (strcmp (result + 2 + 4000, " 99") == 0);
ASSERT (retval == strlen (result));
{
int retval =
my_snprintf (result, sizeof (result), "%.511f %d", 1.0, 99);
- size_t i;
ASSERT (result[0] == '1');
ASSERT (result[1] == '.');
- for (i = 0; i < 511; i++)
+ for (size_t i = 0; i < 511; i++)
ASSERT (result[2 + i] == '0');
ASSERT (strcmp (result + 2 + 511, " 99") == 0);
ASSERT (retval == strlen (result));
/* To verify that these tests succeed, it is necessary to run them under
a tool that checks against invalid memory accesses, such as ElectricFence
or "valgrind --tool=memcheck". */
- {
- size_t i;
+ for (size_t i = 1; i <= 8; i++)
+ {
+ char *block;
+ int retval;
- for (i = 1; i <= 8; i++)
- {
- char *block;
- int retval;
-
- block = (char *) malloc (i);
- memcpy (block, "abcdefgh", i);
- retval = my_snprintf (result, sizeof (result), "%.*s", (int) i, block);
- ASSERT (memcmp (result, block, i) == 0);
- ASSERT (result[i] == '\0');
- ASSERT (retval == strlen (result));
- free (block);
- }
- }
- {
- size_t i;
+ block = (char *) malloc (i);
+ memcpy (block, "abcdefgh", i);
+ retval = my_snprintf (result, sizeof (result), "%.*s", (int) i, block);
+ ASSERT (memcmp (result, block, i) == 0);
+ ASSERT (result[i] == '\0');
+ ASSERT (retval == strlen (result));
+ free (block);
+ }
+ for (size_t i = 1; i <= 8; i++)
+ {
+ wchar_t *block;
+ int retval;
- for (i = 1; i <= 8; i++)
- {
- wchar_t *block;
- size_t j;
- int retval;
-
- block = (wchar_t *) malloc (i * sizeof (wchar_t));
- for (j = 0; j < i; j++)
- block[j] = "abcdefgh"[j];
- retval = my_snprintf (result, sizeof (result), "%.*ls", (int) i, block);
- ASSERT (memcmp (result, "abcdefgh", i) == 0);
- ASSERT (result[i] == '\0');
- ASSERT (retval == strlen (result));
- free (block);
- }
- }
+ block = (wchar_t *) malloc (i * sizeof (wchar_t));
+ for (size_t j = 0; j < i; j++)
+ block[j] = "abcdefgh"[j];
+ retval = my_snprintf (result, sizeof (result), "%.*ls", (int) i, block);
+ ASSERT (memcmp (result, "abcdefgh", i) == 0);
+ ASSERT (result[i] == '\0');
+ ASSERT (retval == strlen (result));
+ free (block);
+ }
/* Test the support of the %c format directive. */
main ()
{
char buf[8];
- int size;
int retval;
retval = snprintf (NULL, 0, "%d", 12345);
ASSERT (retval == 5);
- for (size = 0; size <= 8; size++)
+ for (int size = 0; size <= 8; size++)
{
memcpy (buf, "DEADBEEF", 8);
retval = snprintf (buf, size, "%d", 12345);
{ /* This test would fail on AIX 7.1. */
ptrdiff_t retval =
my_snzprintf (result, sizeof (result), "%.4000d %d", 1234567, 99);
- size_t i;
- for (i = 0; i < 4000 - 7; i++)
+ for (size_t i = 0; i < 4000 - 7; i++)
ASSERT (result[i] == '0');
ASSERT (strcmp (result + 4000 - 7, "1234567 99") == 0);
ASSERT (retval == strlen (result));
ASSERT (0);
}
- int fd;
- for (fd = 3; fd < 7; fd++)
+ for (int fd = 3; fd < 7; fd++)
if (!(is_qemu && fd == 3))
{
errno = 0;
main (int argc, char *argv[])
{
int test;
- int fd;
if (argc != 3)
{
/* Plug any file descriptor leaks inherited from outside world before
starting, so that child has a clean slate (at least for the fds that we
might be manipulating). */
- for (fd = 3; fd < 7; fd++)
+ for (int fd = 3; fd < 7; fd++)
close (fd);
test_pipe (argv[1], test >= 4);
int fd[1];
pid_t pid;
- {
- size_t i;
-
- for (i = 0; i < 2; i++)
- {
- const char *progname =
- (i == 0 ? "executable-script" : "executable-script.sh");
- const char *prog_path =
- (i == 0 ? SRCDIR "executable-script" : SRCDIR "executable-script.sh");
- const char *prog_argv[2] = { prog_path, NULL };
-
- pid = create_pipe_in (progname, prog_argv[0], prog_argv, NULL, NULL,
- NULL, false, true, false, fd);
- if (pid >= 0)
- {
- /* Wait for child. */
- ASSERT (wait_subprocess (pid, progname, true, true, true, false,
- NULL)
- == 127);
- }
- else
- {
- ASSERT (pid == -1);
- ASSERT (errno == ENOEXEC);
- }
- }
- }
+ for (size_t i = 0; i < 2; i++)
+ {
+ const char *progname =
+ (i == 0 ? "executable-script" : "executable-script.sh");
+ const char *prog_path =
+ (i == 0 ? SRCDIR "executable-script" : SRCDIR "executable-script.sh");
+ const char *prog_argv[2] = { prog_path, NULL };
+
+ pid = create_pipe_in (progname, prog_argv[0], prog_argv, NULL, NULL,
+ NULL, false, true, false, fd);
+ if (pid >= 0)
+ {
+ /* Wait for child. */
+ ASSERT (wait_subprocess (pid, progname, true, true, true, false,
+ NULL)
+ == 127);
+ }
+ else
+ {
+ ASSERT (pid == -1);
+ ASSERT (errno == ENOEXEC);
+ }
+ }
#if defined _WIN32 && !defined __CYGWIN__
/* On native Windows, scripts - even with '#!' marker - are not executable.
/* Check a spin-lock initialized through gl_spinlock_init. */
{
gl_spinlock_define (, local_spin_lock)
- int i;
gl_spinlock_init (local_spin_lock);
- for (i = 0; i < 10; i++)
+ for (int i = 0; i < 10; i++)
{
gl_spinlock_lock (local_spin_lock);
gl_spinlock_unlock (local_spin_lock);
static void
check_accounts (void)
{
- int i, sum;
+ int sum;
sum = 0;
- for (i = 0; i < ACCOUNT_COUNT; i++)
+ for (int i = 0; i < ACCOUNT_COUNT; i++)
sum += account[i];
if (sum != ACCOUNT_COUNT * 1000)
abort ();
static void *
lock_mutator_thread (void *arg)
{
- int repeat;
-
- for (repeat = REPEAT_COUNT; repeat > 0; repeat--)
+ for (int repeat = REPEAT_COUNT; repeat > 0; repeat--)
{
int i1, i2, value;
static void
test_asyncsafe_spin (void)
{
- int i;
gl_thread_t checkerthread;
gl_thread_t threads[THREAD_COUNT];
/* Initialization. */
- for (i = 0; i < ACCOUNT_COUNT; i++)
+ for (int i = 0; i < ACCOUNT_COUNT; i++)
account[i] = 1000;
init_atomic_int (&lock_checker_done);
set_atomic_int_value (&lock_checker_done, 0);
/* Spawn the threads. */
checkerthread = gl_thread_create (lock_checker_thread, NULL);
- for (i = 0; i < THREAD_COUNT; i++)
+ for (int i = 0; i < THREAD_COUNT; i++)
threads[i] = gl_thread_create (lock_mutator_thread, NULL);
/* Wait for the threads to terminate. */
- for (i = 0; i < THREAD_COUNT; i++)
+ for (int i = 0; i < THREAD_COUNT; i++)
gl_thread_join (threads[i], NULL);
set_atomic_int_value (&lock_checker_done, 1);
gl_thread_join (checkerthread, NULL);
{ 1.234321234321234e35, "123432123432123*********************.000000" },
{ 1.234321234321234e36, "123432123432123**********************.000000" }
};
- size_t k;
- for (k = 0; k < SIZEOF (data); k++)
+ for (size_t k = 0; k < SIZEOF (data); k++)
{
int retval =
my_sprintf (result, "%f", data[k].value);
{ 1.234321234321234e35L, "123432123432123*********************.000000" },
{ 1.234321234321234e36L, "123432123432123**********************.000000" }
};
- size_t k;
- for (k = 0; k < SIZEOF (data); k++)
+ for (size_t k = 0; k < SIZEOF (data); k++)
{
int retval =
my_sprintf (result, "%Lf", data[k].value);
{ 1.234321234321234e35, "1.234321e+35" },
{ 1.234321234321234e36, "1.234321e+36" }
};
- size_t k;
- for (k = 0; k < SIZEOF (data); k++)
+ for (size_t k = 0; k < SIZEOF (data); k++)
{
int retval =
my_sprintf (result, "%e", data[k].value);
{ 1.234321234321234e35L, "1.234321e+35" },
{ 1.234321234321234e36L, "1.234321e+36" }
};
- size_t k;
- for (k = 0; k < SIZEOF (data); k++)
+ for (size_t k = 0; k < SIZEOF (data); k++)
{
int retval =
my_sprintf (result, "%Le", data[k].value);
{ 1.234321234321234e35, "1.23432e+35" },
{ 1.234321234321234e36, "1.23432e+36" }
};
- size_t k;
- for (k = 0; k < SIZEOF (data); k++)
+ for (size_t k = 0; k < SIZEOF (data); k++)
{
int retval =
my_sprintf (result, "%g", data[k].value);
{ 1.234321234321234e35L, "1.23432e+35" },
{ 1.234321234321234e36L, "1.23432e+36" }
};
- size_t k;
- for (k = 0; k < SIZEOF (data); k++)
+ for (size_t k = 0; k < SIZEOF (data); k++)
{
int retval =
my_sprintf (result, "%Lg", data[k].value);
{
int retval =
my_sprintf (result, "%.4000d %d", 1234567, 99);
- size_t i;
- for (i = 0; i < 4000 - 7; i++)
+ for (size_t i = 0; i < 4000 - 7; i++)
ASSERT (result[i] == '0');
ASSERT (strcmp (result + 4000 - 7, "1234567 99") == 0);
ASSERT (retval == strlen (result));
{
int retval =
my_sprintf (result, "%.*d %d", 4000, 1234567, 99);
- size_t i;
- for (i = 0; i < 4000 - 7; i++)
+ for (size_t i = 0; i < 4000 - 7; i++)
ASSERT (result[i] == '0');
ASSERT (strcmp (result + 4000 - 7, "1234567 99") == 0);
ASSERT (retval == strlen (result));
{
int retval =
my_sprintf (result, "%.4000d %d", -1234567, 99);
- size_t i;
ASSERT (result[0] == '-');
- for (i = 0; i < 4000 - 7; i++)
+ for (size_t i = 0; i < 4000 - 7; i++)
ASSERT (result[1 + i] == '0');
ASSERT (strcmp (result + 1 + 4000 - 7, "1234567 99") == 0);
ASSERT (retval == strlen (result));
{
int retval =
my_sprintf (result, "%.4000u %d", 1234567, 99);
- size_t i;
- for (i = 0; i < 4000 - 7; i++)
+ for (size_t i = 0; i < 4000 - 7; i++)
ASSERT (result[i] == '0');
ASSERT (strcmp (result + 4000 - 7, "1234567 99") == 0);
ASSERT (retval == strlen (result));
{
int retval =
my_sprintf (result, "%.4000o %d", 1234567, 99);
- size_t i;
- for (i = 0; i < 4000 - 7; i++)
+ for (size_t i = 0; i < 4000 - 7; i++)
ASSERT (result[i] == '0');
ASSERT (strcmp (result + 4000 - 7, "4553207 99") == 0);
ASSERT (retval == strlen (result));
{
int retval =
my_sprintf (result, "%.4000x %d", 1234567, 99);
- size_t i;
- for (i = 0; i < 4000 - 6; i++)
+ for (size_t i = 0; i < 4000 - 6; i++)
ASSERT (result[i] == '0');
ASSERT (strcmp (result + 4000 - 6, "12d687 99") == 0);
ASSERT (retval == strlen (result));
{
int retval =
my_sprintf (result, "%#.4000x %d", 1234567, 99);
- size_t i;
ASSERT (result[0] == '0');
ASSERT (result[1] == 'x');
- for (i = 0; i < 4000 - 6; i++)
+ for (size_t i = 0; i < 4000 - 6; i++)
ASSERT (result[2 + i] == '0');
ASSERT (strcmp (result + 2 + 4000 - 6, "12d687 99") == 0);
ASSERT (retval == strlen (result));
{
int retval =
my_sprintf (result, "%.4000f %d", 1.0, 99);
- size_t i;
ASSERT (result[0] == '1');
ASSERT (result[1] == '.');
- for (i = 0; i < 4000; i++)
+ for (size_t i = 0; i < 4000; i++)
ASSERT (result[2 + i] == '0');
ASSERT (strcmp (result + 2 + 4000, " 99") == 0);
ASSERT (retval == strlen (result));
{
int retval =
my_sprintf (result, "%.511f %d", 1.0, 99);
- size_t i;
ASSERT (result[0] == '1');
ASSERT (result[1] == '.');
- for (i = 0; i < 511; i++)
+ for (size_t i = 0; i < 511; i++)
ASSERT (result[2 + i] == '0');
ASSERT (strcmp (result + 2 + 511, " 99") == 0);
ASSERT (retval == strlen (result));
/* To verify that these tests succeed, it is necessary to run them under
a tool that checks against invalid memory accesses, such as ElectricFence
or "valgrind --tool=memcheck". */
- {
- size_t i;
-
- for (i = 1; i <= 8; i++)
- {
- char *block;
- int retval;
-
- block = (char *) malloc (i);
- memcpy (block, "abcdefgh", i);
- retval = my_sprintf (result, "%.*s", (int) i, block);
- ASSERT (memcmp (result, block, i) == 0);
- ASSERT (result[i] == '\0');
- ASSERT (retval == strlen (result));
- free (block);
- }
- }
- {
- size_t i;
-
- for (i = 1; i <= 8; i++)
- {
- wchar_t *block;
- size_t j;
- int retval;
-
- block = (wchar_t *) malloc (i * sizeof (wchar_t));
- for (j = 0; j < i; j++)
- block[j] = "abcdefgh"[j];
- retval = my_sprintf (result, "%.*ls", (int) i, block);
- ASSERT (memcmp (result, "abcdefgh", i) == 0);
- ASSERT (result[i] == '\0');
- ASSERT (retval == strlen (result));
- free (block);
- }
- }
+ for (size_t i = 1; i <= 8; i++)
+ {
+ char *block;
+ int retval;
+
+ block = (char *) malloc (i);
+ memcpy (block, "abcdefgh", i);
+ retval = my_sprintf (result, "%.*s", (int) i, block);
+ ASSERT (memcmp (result, block, i) == 0);
+ ASSERT (result[i] == '\0');
+ ASSERT (retval == strlen (result));
+ free (block);
+ }
+ for (size_t i = 1; i <= 8; i++)
+ {
+ wchar_t *block;
+ int retval;
+
+ block = (wchar_t *) malloc (i * sizeof (wchar_t));
+ for (size_t j = 0; j < i; j++)
+ block[j] = "abcdefgh"[j];
+ retval = my_sprintf (result, "%.*ls", (int) i, block);
+ ASSERT (memcmp (result, "abcdefgh", i) == 0);
+ ASSERT (result[i] == '\0');
+ ASSERT (retval == strlen (result));
+ free (block);
+ }
/* Test the support of the %c format directive. */
static void
test_function (void)
{
- int i;
- int j;
const DOUBLE TWO_MANT_DIG =
/* Assume MANT_DIG <= 5 * 31.
Use the identity
* (DOUBLE) (1U << ((MANT_DIG - 1 + 4) / 5));
/* Randomized tests. */
- for (i = 0; i < SIZEOF (RANDOM); i++)
+ for (int i = 0; i < SIZEOF (RANDOM); i++)
{
DOUBLE x = L_(16.0) * RANDOM[i]; /* 0.0 <= x <= 16.0 */
DOUBLE y = SQRT (x);
&& err < L_(16.0) / TWO_MANT_DIG);
}
- for (i = 0; i < SIZEOF (RANDOM) / 4; i++)
- for (j = 0; j < SIZEOF (RANDOM) / 4; j++)
+ for (int i = 0; i < SIZEOF (RANDOM) / 4; i++)
+ for (int j = 0; j < SIZEOF (RANDOM) / 4; j++)
{
DOUBLE x = L_(16.0) * RANDOM[i]; /* 0.0 <= x <= 16.0 */
DOUBLE y = L_(16.0) * RANDOM[j]; /* 0.0 <= y <= 16.0 */
Also verify that there are no unexpected modifications to the contents of
these blocks. */
{
- unsigned int repeat;
char *blocks[SIZEOF (block_sizes)];
- {
- size_t i;
+ for (size_t i = 0; i < SIZEOF (block_sizes); i++)
+ blocks[i] = NULL;
- for (i = 0; i < SIZEOF (block_sizes); i++)
- blocks[i] = NULL;
- }
-
- for (repeat = 0; repeat < 100000; repeat++)
+ for (unsigned int repeat = 0; repeat < 100000; repeat++)
{
unsigned int operation = RANDOM (2);
}
/* Free the remaining blocks. */
- {
- size_t i;
-
- for (i = 0; i < SIZEOF (block_sizes); i++)
- if (blocks[i] != NULL)
- {
- uintptr_t block = (uintptr_t) blocks[i];
- size_t size = block_sizes[i];
- verify_block (block, size);
- free_block (block);
- }
- }
+ for (size_t i = 0; i < SIZEOF (block_sizes); i++)
+ if (blocks[i] != NULL)
+ {
+ uintptr_t block = (uintptr_t) blocks[i];
+ size_t size = block_sizes[i];
+ verify_block (block, size);
+ free_block (block);
+ }
}
return test_exit_status;
static void
prepare_test (struct stat *statinfo, struct timespec *modtimes)
{
- int i;
-
create_file (filename_stamp1);
nap ();
create_file (filename_testfile);
do_stat (filename_stamp3, &statinfo[3]);
/* Now use our access functions. */
- for (i = 0; i < NFILES; ++i)
+ for (int i = 0; i < NFILES; ++i)
{
modtimes[i] = get_stat_mtime (&statinfo[i]);
}
static void
test_mtime (const struct stat *statinfo, struct timespec *modtimes)
{
- int i;
-
/* Use the struct stat fields directly. */
/* mtime(stamp1) < mtime(stamp2) */
ASSERT (statinfo[0].st_mtime < statinfo[2].st_mtime
&& modtimes[2].tv_nsec < modtimes[3].tv_nsec));
/* verify equivalence */
- for (i = 0; i < NFILES; ++i)
+ for (int i = 0; i < NFILES; ++i)
{
struct timespec ts;
ts = get_stat_mtime (&statinfo[i]);
const struct timespec *modtimes,
struct timespec *birthtimes)
{
- int i;
-
/* Collect the birth times. */
- for (i = 0; i < NFILES; ++i)
+ for (int i = 0; i < NFILES; ++i)
{
birthtimes[i] = get_stat_birthtime (&statinfo[i]);
if (birthtimes[i].tv_nsec < 0)
{
char from[10];
char to[10];
- int i, j, k, h;
char *ret;
- for (i = 0; i < 10; i++)
- for (j = 0; j < 10; j++)
- for (k = 0; k < 10; k++)
+ for (int i = 0; i < 10; i++)
+ for (int j = 0; j < 10; j++)
+ for (int k = 0; k < 10; k++)
{
memset (from, 'X', sizeof from);
memcpy (from, "SourceString", i);
if (k < 10) to[k] = '\0';
ret = stpncpy (to, from, j);
printf ("i = %2d, j = %2d, k = %2d: from = ", i, j, k);
- for (h = 0; h < 10; h++)
+ for (int h = 0; h < 10; h++)
if (from[h] >= 0x20 && from[h] < 0x7f)
putchar (from[h]);
else
printf ("\\x%02x", from[h]);
printf (" to = ");
- for (h = 0; h < 10; h++)
+ for (int h = 0; h < 10; h++)
if (to[h] >= 0x20 && to[h] < 0x7f)
putchar (to[h]);
else
"with_multilib_list\n";
size_t h_len = strlen (h);
char *haystack = malloc (h_len + 1);
- size_t i;
ASSERT (haystack);
- for (i = 0; i < h_len - strlen (needle); i++)
+ for (size_t i = 0; i < h_len - strlen (needle); i++)
{
const char *p;
memcpy (haystack, h, h_len + 1);
}
/* Alignment tests. */
- {
- int i, j;
- for (i = 0; i < 32; i++)
- {
- for (j = 0; j < 256; j++)
- input[i + j] = (j + 1) & 0xff;
- for (j = 1; j < 256; j++)
- {
- ASSERT (strchrnul (input + i, j) == input + i + j - 1);
- input[i + j - 1] = (j == 1 ? 2 : 1);
- ASSERT (strchrnul (input + i, j) == input + i + 255);
- input[i + j - 1] = j;
- }
- }
- }
+ for (int i = 0; i < 32; i++)
+ {
+ for (int j = 0; j < 256; j++)
+ input[i + j] = (j + 1) & 0xff;
+ for (int j = 1; j < 256; j++)
+ {
+ ASSERT (strchrnul (input + i, j) == input + i + j - 1);
+ input[i + j - 1] = (j == 1 ? 2 : 1);
+ ASSERT (strchrnul (input + i, j) == input + i + 255);
+ input[i + j - 1] = j;
+ }
+ }
free (input);
that no out-of-bounds writes occur. */
{
int errs[] = { EACCES, 0, -3, };
- int j;
buf[sizeof buf - 1] = '\0';
- for (j = 0; j < SIZEOF (errs); j++)
+ for (int j = 0; j < SIZEOF (errs); j++)
{
int err = errs[j];
char buf2[sizeof buf] = "";
size_t len;
- size_t i;
strerror_r (err, buf2, sizeof buf2);
len = strlen (buf2);
ASSERT (len < sizeof buf);
- for (i = 0; i <= len; i++)
+ for (size_t i = 0; i <= len; i++)
{
memset (buf, '^', sizeof buf - 1);
errno = 0;
iconveh_replacement_character,
iconveh_escape_sequence
};
- size_t indirect;
- size_t h;
- size_t o;
- size_t i;
/* Assume that iconv() supports at least the encodings ASCII, ISO-8859-1,
ISO-8859-2, UTF-8, and with libiconv or glibc also GB18030. */
/* ------------------------ Test mem_cd_iconveh() ------------------------ */
/* Test conversion from ISO-8859-2 to ISO-8859-1 with no errors. */
- for (indirect = 0; indirect <= 1; indirect++)
+ for (size_t indirect = 0; indirect <= 1; indirect++)
{
- for (h = 0; h < SIZEOF (handlers); h++)
+ for (size_t h = 0; h < SIZEOF (handlers); h++)
{
enum iconv_ilseq_handler handler = handlers[h];
static const char input[] = "\304rger mit b\366sen B\374bchen ohne Augenma\337";
static const char expected[] = "\304rger mit b\366sen B\374bchen ohne Augenma\337";
- for (o = 0; o < 2; o++)
+ for (size_t o = 0; o < 2; o++)
{
size_t *offsets = (o ? new_offsets (strlen (input)) : NULL);
char *result = NULL;
ASSERT (result != NULL && memcmp (result, expected, strlen (expected)) == 0);
if (o)
{
- for (i = 0; i < 37; i++)
+ for (size_t i = 0; i < 37; i++)
ASSERT (offsets[i] == i);
ASSERT (offsets[37] == MAGIC);
free (offsets);
}
/* Test conversion from ASCII to ISO-8859-1 with invalid input (EILSEQ). */
- for (indirect = 0; indirect <= 1; indirect++)
+ for (size_t indirect = 0; indirect <= 1; indirect++)
{
- for (h = 0; h < SIZEOF (handlers); h++)
+ for (size_t h = 0; h < SIZEOF (handlers); h++)
{
enum iconv_ilseq_handler handler = handlers[h];
static const char input[] = "Rafa\263 Maszkowski"; /* Rafa? Maszkowski */
- for (o = 0; o < 2; o++)
+ for (size_t o = 0; o < 2; o++)
{
size_t *offsets = (o ? new_offsets (strlen (input)) : NULL);
char *result = NULL;
ASSERT (result != NULL && memcmp (result, expected, strlen (expected)) == 0);
if (o)
{
- for (i = 0; i < 16; i++)
+ for (size_t i = 0; i < 16; i++)
ASSERT (offsets[i] == i);
ASSERT (offsets[16] == MAGIC);
free (offsets);
}
/* Test conversion from ISO-8859-2 to ISO-8859-1 with EILSEQ. */
- for (indirect = 0; indirect <= 1; indirect++)
+ for (size_t indirect = 0; indirect <= 1; indirect++)
{
- for (h = 0; h < SIZEOF (handlers); h++)
+ for (size_t h = 0; h < SIZEOF (handlers); h++)
{
enum iconv_ilseq_handler handler = handlers[h];
static const char input[] = "Rafa\263 Maszkowski"; /* Rafał Maszkowski */
- for (o = 0; o < 2; o++)
+ for (size_t o = 0; o < 2; o++)
{
size_t *offsets = (o ? new_offsets (strlen (input)) : NULL);
char *result = NULL;
ASSERT (result != NULL && memcmp (result, expected, strlen (expected)) == 0);
if (o)
{
- for (i = 0; i < 16; i++)
+ for (size_t i = 0; i < 16; i++)
ASSERT (offsets[i] == i);
ASSERT (offsets[16] == MAGIC);
free (offsets);
ASSERT (result != NULL && memcmp (result, expected, strlen (expected)) == 0);
if (o)
{
- for (i = 0; i < 16; i++)
+ for (size_t i = 0; i < 16; i++)
ASSERT (offsets[i] == (i < 5 ? i :
i + 5));
ASSERT (offsets[16] == MAGIC);
}
/* Test conversion from ISO-8859-1 to UTF-8 with no errors. */
- for (h = 0; h < SIZEOF (handlers); h++)
+ for (size_t h = 0; h < SIZEOF (handlers); h++)
{
enum iconv_ilseq_handler handler = handlers[h];
static const char input[] = "\304rger mit b\366sen B\374bchen ohne Augenma\337";
static const char expected[] = "\303\204rger mit b\303\266sen B\303\274bchen ohne Augenma\303\237";
- for (o = 0; o < 2; o++)
+ for (size_t o = 0; o < 2; o++)
{
size_t *offsets = (o ? new_offsets (strlen (input)) : NULL);
char *result = NULL;
ASSERT (result != NULL && memcmp (result, expected, strlen (expected)) == 0);
if (o)
{
- for (i = 0; i < 37; i++)
+ for (size_t i = 0; i < 37; i++)
ASSERT (offsets[i] == (i < 1 ? i :
i < 12 ? i + 1 :
i < 18 ? i + 2 :
# if (defined _LIBICONV_VERSION && !(_LIBICONV_VERSION == 0x10b && defined __APPLE__)) || (defined __GLIBC__ && !defined __UCLIBC__)
/* Test conversion from ISO-8859-1 to GB18030 with no errors. */
- for (h = 0; h < SIZEOF (handlers); h++)
+ for (size_t h = 0; h < SIZEOF (handlers); h++)
{
enum iconv_ilseq_handler handler = handlers[h];
static const char input[] = "\304rger mit b\366sen B\374bchen ohne Augenma\337";
static const char expected[] = "\2010\2072rger mit b\2010\2132sen B\250\271bchen ohne Augenma\2010\2118";
- for (o = 0; o < 2; o++)
+ for (size_t o = 0; o < 2; o++)
{
size_t *offsets = (o ? new_offsets (strlen (input)) : NULL);
char *result = NULL;
ASSERT (result != NULL && memcmp (result, expected, strlen (expected)) == 0);
if (o)
{
- for (i = 0; i < 37; i++)
+ for (size_t i = 0; i < 37; i++)
ASSERT (offsets[i] == (i < 1 ? i :
i < 12 ? i + 3 :
i < 18 ? i + 6 :
# endif
/* Test conversion from UTF-8 to ISO-8859-1 with no errors. */
- for (h = 0; h < SIZEOF (handlers); h++)
+ for (size_t h = 0; h < SIZEOF (handlers); h++)
{
enum iconv_ilseq_handler handler = handlers[h];
static const char input[] = "\303\204rger mit b\303\266sen B\303\274bchen ohne Augenma\303\237";
static const char expected[] = "\304rger mit b\366sen B\374bchen ohne Augenma\337";
- for (o = 0; o < 2; o++)
+ for (size_t o = 0; o < 2; o++)
{
size_t *offsets = (o ? new_offsets (strlen (input)) : NULL);
char *result = NULL;
ASSERT (result != NULL && memcmp (result, expected, strlen (expected)) == 0);
if (o)
{
- for (i = 0; i < 41; i++)
+ for (size_t i = 0; i < 41; i++)
ASSERT (offsets[i] == (i < 1 ? i :
i == 1 ? (size_t)(-1) :
i < 13 ? i - 1 :
}
/* Test conversion from ASCII to UTF-8 with invalid input (EILSEQ). */
- for (h = 0; h < SIZEOF (handlers); h++)
+ for (size_t h = 0; h < SIZEOF (handlers); h++)
{
enum iconv_ilseq_handler handler = handlers[h];
static const char input[] = "Rafa\263 Maszkowski"; /* Rafa? Maszkowski */
- for (o = 0; o < 2; o++)
+ for (size_t o = 0; o < 2; o++)
{
size_t *offsets = (o ? new_offsets (strlen (input)) : NULL);
char *result = NULL;
ASSERT (result != NULL && memcmp (result, expected, strlen (expected)) == 0);
if (o)
{
- for (i = 0; i < 16; i++)
+ for (size_t i = 0; i < 16; i++)
ASSERT (offsets[i] == i);
ASSERT (offsets[16] == MAGIC);
free (offsets);
ASSERT (result != NULL && memcmp (result, expected, strlen (expected)) == 0);
if (o)
{
- for (i = 0; i < 16; i++)
+ for (size_t i = 0; i < 16; i++)
ASSERT (offsets[i] == (i < 5 ? i : i + 2));
ASSERT (offsets[16] == MAGIC);
free (offsets);
/* Test conversion from ASCII to GB18030 with invalid input (EILSEQ).
Note: glibc's GB18030 converter was buggy in glibc-2.15; fixed by
Andreas Schwab on 2012-02-06. */
- for (h = 0; h < SIZEOF (handlers); h++)
+ for (size_t h = 0; h < SIZEOF (handlers); h++)
{
enum iconv_ilseq_handler handler = handlers[h];
static const char input[] = "Rafa\263 Maszkowski"; /* Rafa? Maszkowski */
- for (o = 0; o < 2; o++)
+ for (size_t o = 0; o < 2; o++)
{
size_t *offsets = (o ? new_offsets (strlen (input)) : NULL);
char *result = NULL;
ASSERT (result != NULL && memcmp (result, expected, strlen (expected)) == 0);
if (o)
{
- for (i = 0; i < 16; i++)
+ for (size_t i = 0; i < 16; i++)
ASSERT (offsets[i] == i);
ASSERT (offsets[16] == MAGIC);
free (offsets);
ASSERT (result != NULL && memcmp (result, expected, strlen (expected)) == 0);
if (o)
{
- for (i = 0; i < 16; i++)
+ for (size_t i = 0; i < 16; i++)
ASSERT (offsets[i] == (i < 5 ? i : i + 3));
ASSERT (offsets[16] == MAGIC);
free (offsets);
# endif
/* Test conversion from UTF-8 to ISO-8859-1 with EILSEQ. */
- for (h = 0; h < SIZEOF (handlers); h++)
+ for (size_t h = 0; h < SIZEOF (handlers); h++)
{
enum iconv_ilseq_handler handler = handlers[h];
static const char input[] = "Rafa\305\202 Maszkowski"; /* Rafał Maszkowski */
- for (o = 0; o < 2; o++)
+ for (size_t o = 0; o < 2; o++)
{
size_t *offsets = (o ? new_offsets (strlen (input)) : NULL);
char *result = NULL;
ASSERT (result != NULL && memcmp (result, expected, strlen (expected)) == 0);
if (o)
{
- for (i = 0; i < 17; i++)
+ for (size_t i = 0; i < 17; i++)
ASSERT (offsets[i] == (i < 5 ? i :
i == 5 ? (size_t)(-1) :
i - 1));
ASSERT (result != NULL && memcmp (result, expected, strlen (expected)) == 0);
if (o)
{
- for (i = 0; i < 17; i++)
+ for (size_t i = 0; i < 17; i++)
ASSERT (offsets[i] == (i < 5 ? i :
i == 5 ? (size_t)(-1) :
i + 4));
}
/* Test conversion from UTF-8 to ISO-8859-1 with EINVAL. */
- for (h = 0; h < SIZEOF (handlers); h++)
+ for (size_t h = 0; h < SIZEOF (handlers); h++)
{
enum iconv_ilseq_handler handler = handlers[h];
static const char input[] = "\342";
- for (o = 0; o < 2; o++)
+ for (size_t o = 0; o < 2; o++)
{
size_t *offsets = (o ? new_offsets (strlen (input)) : NULL);
char *result = NULL;
-1 / EILSEQ when converting the 7th byte of the input "+VDLYP9hA". */
# if !(defined __sun && !defined _LIBICONV_VERSION)
/* Test conversion from UTF-7 to UTF-8 with EINVAL. */
- for (h = 0; h < SIZEOF (handlers); h++)
+ for (size_t h = 0; h < SIZEOF (handlers); h++)
{
enum iconv_ilseq_handler handler = handlers[h];
/* This is base64 encoded 0x54 0x32 0xD8 0x3F 0xD8 0x40. It would
# if (defined _LIBICONV_VERSION && !(_LIBICONV_VERSION == 0x10b && defined __APPLE__)) || (defined __GLIBC__ && !defined __UCLIBC__)
/* Test conversion from UTF-7 to GB18030 with EINVAL. */
- for (h = 0; h < SIZEOF (handlers); h++)
+ for (size_t h = 0; h < SIZEOF (handlers); h++)
{
enum iconv_ilseq_handler handler = handlers[h];
/* This is base64 encoded 0x54 0x32 0xD8 0x3F 0xD8 0x40. It would
the input "+2D/YQNhB" to U+1FED8 U+3FD8 U+40D8. */
# if !(defined __NetBSD__ && !defined _LIBICONV_VERSION)
/* Test conversion from UTF-7 to UTF-8 with EILSEQ. */
- for (h = 0; h < SIZEOF (handlers); h++)
+ for (size_t h = 0; h < SIZEOF (handlers); h++)
{
enum iconv_ilseq_handler handler = handlers[h];
/* This is base64 encoded 0xD8 0x3F 0xD8 0x40 0xD8 0x41. It would
/* Test conversion from UTF-7 to GB18030 with EILSEQ.
Note: glibc's GB18030 converter was buggy in glibc-2.15; fixed by
Andreas Schwab on 2012-02-06. */
- for (h = 0; h < SIZEOF (handlers); h++)
+ for (size_t h = 0; h < SIZEOF (handlers); h++)
{
enum iconv_ilseq_handler handler = handlers[h];
/* This is base64 encoded 0xD8 0x3F 0xD8 0x40 0xD8 0x41. It would
/* ------------------------ Test str_cd_iconveh() ------------------------ */
/* Test conversion from ISO-8859-2 to ISO-8859-1 with no errors. */
- for (indirect = 0; indirect <= 1; indirect++)
+ for (size_t indirect = 0; indirect <= 1; indirect++)
{
- for (h = 0; h < SIZEOF (handlers); h++)
+ for (size_t h = 0; h < SIZEOF (handlers); h++)
{
enum iconv_ilseq_handler handler = handlers[h];
static const char input[] = "\304rger mit b\366sen B\374bchen ohne Augenma\337";
}
/* Test conversion from ASCII to ISO-8859-1 with invalid input (EILSEQ). */
- for (indirect = 0; indirect <= 1; indirect++)
+ for (size_t indirect = 0; indirect <= 1; indirect++)
{
- for (h = 0; h < SIZEOF (handlers); h++)
+ for (size_t h = 0; h < SIZEOF (handlers); h++)
{
enum iconv_ilseq_handler handler = handlers[h];
static const char input[] = "Rafa\263 Maszkowski"; /* Rafa? Maszkowski */
}
/* Test conversion from ISO-8859-2 to ISO-8859-1 with EILSEQ. */
- for (indirect = 0; indirect <= 1; indirect++)
+ for (size_t indirect = 0; indirect <= 1; indirect++)
{
- for (h = 0; h < SIZEOF (handlers); h++)
+ for (size_t h = 0; h < SIZEOF (handlers); h++)
{
enum iconv_ilseq_handler handler = handlers[h];
static const char input[] = "Rafa\263 Maszkowski"; /* Rafał Maszkowski */
}
/* Test conversion from ISO-8859-1 to UTF-8 with no errors. */
- for (h = 0; h < SIZEOF (handlers); h++)
+ for (size_t h = 0; h < SIZEOF (handlers); h++)
{
enum iconv_ilseq_handler handler = handlers[h];
static const char input[] = "\304rger mit b\366sen B\374bchen ohne Augenma\337";
# if (defined _LIBICONV_VERSION && !(_LIBICONV_VERSION == 0x10b && defined __APPLE__)) || (defined __GLIBC__ && !defined __UCLIBC__)
/* Test conversion from ISO-8859-1 to GB18030 with no errors. */
- for (h = 0; h < SIZEOF (handlers); h++)
+ for (size_t h = 0; h < SIZEOF (handlers); h++)
{
enum iconv_ilseq_handler handler = handlers[h];
static const char input[] = "\304rger mit b\366sen B\374bchen ohne Augenma\337";
# endif
/* Test conversion from UTF-8 to ISO-8859-1 with no errors. */
- for (h = 0; h < SIZEOF (handlers); h++)
+ for (size_t h = 0; h < SIZEOF (handlers); h++)
{
enum iconv_ilseq_handler handler = handlers[h];
static const char input[] = "\303\204rger mit b\303\266sen B\303\274bchen ohne Augenma\303\237";
}
/* Test conversion from ASCII to UTF-8 with invalid input (EILSEQ). */
- for (h = 0; h < SIZEOF (handlers); h++)
+ for (size_t h = 0; h < SIZEOF (handlers); h++)
{
enum iconv_ilseq_handler handler = handlers[h];
static const char input[] = "Rafa\263 Maszkowski"; /* Rafa? Maszkowski */
/* Test conversion from ASCII to GB18030 with invalid input (EILSEQ).
Note: glibc's GB18030 converter was buggy in glibc-2.15; fixed by
Andreas Schwab on 2012-02-06. */
- for (h = 0; h < SIZEOF (handlers); h++)
+ for (size_t h = 0; h < SIZEOF (handlers); h++)
{
enum iconv_ilseq_handler handler = handlers[h];
static const char input[] = "Rafa\263 Maszkowski"; /* Rafa? Maszkowski */
# endif
/* Test conversion from UTF-8 to ISO-8859-1 with EILSEQ. */
- for (h = 0; h < SIZEOF (handlers); h++)
+ for (size_t h = 0; h < SIZEOF (handlers); h++)
{
enum iconv_ilseq_handler handler = handlers[h];
static const char input[] = "Costs: 27 \342\202\254"; /* EURO SIGN */
}
/* Test conversion from UTF-8 to ISO-8859-1 with EINVAL. */
- for (h = 0; h < SIZEOF (handlers); h++)
+ for (size_t h = 0; h < SIZEOF (handlers); h++)
{
enum iconv_ilseq_handler handler = handlers[h];
static const char input[] = "\342";
/* ------------------------- Test mem_iconveh() ------------------------- */
/* Test conversion from ISO-8859-2 to ISO-8859-1 with no errors. */
- for (h = 0; h < SIZEOF (handlers); h++)
+ for (size_t h = 0; h < SIZEOF (handlers); h++)
{
enum iconv_ilseq_handler handler = handlers[h];
static const char input[] = "\304rger mit b\366sen B\374bchen ohne Augenma\337";
static const char expected[] = "\304rger mit b\366sen B\374bchen ohne Augenma\337";
- for (o = 0; o < 2; o++)
+ for (size_t o = 0; o < 2; o++)
{
size_t *offsets = (o ? new_offsets (strlen (input)) : NULL);
char *result = NULL;
ASSERT (result != NULL && memcmp (result, expected, strlen (expected)) == 0);
if (o)
{
- for (i = 0; i < 37; i++)
+ for (size_t i = 0; i < 37; i++)
ASSERT (offsets[i] == i);
ASSERT (offsets[37] == MAGIC);
free (offsets);
}
/* Test conversion from ISO-8859-2 to ISO-8859-1 with EILSEQ. */
- for (h = 0; h < SIZEOF (handlers); h++)
+ for (size_t h = 0; h < SIZEOF (handlers); h++)
{
enum iconv_ilseq_handler handler = handlers[h];
static const char input[] = "Rafa\263 Maszkowski"; /* Rafał Maszkowski */
- for (o = 0; o < 2; o++)
+ for (size_t o = 0; o < 2; o++)
{
size_t *offsets = (o ? new_offsets (strlen (input)) : NULL);
char *result = NULL;
ASSERT (result != NULL && memcmp (result, expected, strlen (expected)) == 0);
if (o)
{
- for (i = 0; i < 16; i++)
+ for (size_t i = 0; i < 16; i++)
ASSERT (offsets[i] == i);
ASSERT (offsets[16] == MAGIC);
free (offsets);
ASSERT (result != NULL && memcmp (result, expected, strlen (expected)) == 0);
if (o)
{
- for (i = 0; i < 16; i++)
+ for (size_t i = 0; i < 16; i++)
ASSERT (offsets[i] == (i < 5 ? i :
i + 5));
ASSERT (offsets[16] == MAGIC);
}
/* Test conversion from ISO-8859-1 to UTF-8 with no errors. */
- for (h = 0; h < SIZEOF (handlers); h++)
+ for (size_t h = 0; h < SIZEOF (handlers); h++)
{
enum iconv_ilseq_handler handler = handlers[h];
static const char input[] = "\304rger mit b\366sen B\374bchen ohne Augenma\337";
static const char expected[] = "\303\204rger mit b\303\266sen B\303\274bchen ohne Augenma\303\237";
- for (o = 0; o < 2; o++)
+ for (size_t o = 0; o < 2; o++)
{
size_t *offsets = (o ? new_offsets (strlen (input)) : NULL);
char *result = NULL;
ASSERT (result != NULL && memcmp (result, expected, strlen (expected)) == 0);
if (o)
{
- for (i = 0; i < 37; i++)
+ for (size_t i = 0; i < 37; i++)
ASSERT (offsets[i] == (i < 1 ? i :
i < 12 ? i + 1 :
i < 18 ? i + 2 :
# if (defined _LIBICONV_VERSION && !(_LIBICONV_VERSION == 0x10b && defined __APPLE__)) || (defined __GLIBC__ && !defined __UCLIBC__)
/* Test conversion from ISO-8859-1 to GB18030 with no errors. */
- for (h = 0; h < SIZEOF (handlers); h++)
+ for (size_t h = 0; h < SIZEOF (handlers); h++)
{
enum iconv_ilseq_handler handler = handlers[h];
static const char input[] = "\304rger mit b\366sen B\374bchen ohne Augenma\337";
static const char expected[] = "\2010\2072rger mit b\2010\2132sen B\250\271bchen ohne Augenma\2010\2118";
- for (o = 0; o < 2; o++)
+ for (size_t o = 0; o < 2; o++)
{
size_t *offsets = (o ? new_offsets (strlen (input)) : NULL);
char *result = NULL;
ASSERT (result != NULL && memcmp (result, expected, strlen (expected)) == 0);
if (o)
{
- for (i = 0; i < 37; i++)
+ for (size_t i = 0; i < 37; i++)
ASSERT (offsets[i] == (i < 1 ? i :
i < 12 ? i + 3 :
i < 18 ? i + 6 :
# endif
/* Test conversion from UTF-8 to ISO-8859-1 with no errors. */
- for (h = 0; h < SIZEOF (handlers); h++)
+ for (size_t h = 0; h < SIZEOF (handlers); h++)
{
enum iconv_ilseq_handler handler = handlers[h];
static const char input[] = "\303\204rger mit b\303\266sen B\303\274bchen ohne Augenma\303\237";
static const char expected[] = "\304rger mit b\366sen B\374bchen ohne Augenma\337";
- for (o = 0; o < 2; o++)
+ for (size_t o = 0; o < 2; o++)
{
size_t *offsets = (o ? new_offsets (strlen (input)) : NULL);
char *result = NULL;
ASSERT (result != NULL && memcmp (result, expected, strlen (expected)) == 0);
if (o)
{
- for (i = 0; i < 41; i++)
+ for (size_t i = 0; i < 41; i++)
ASSERT (offsets[i] == (i < 1 ? i :
i == 1 ? (size_t)(-1) :
i < 13 ? i - 1 :
}
/* Test conversion from UTF-8 to ISO-8859-1 with EILSEQ. */
- for (h = 0; h < SIZEOF (handlers); h++)
+ for (size_t h = 0; h < SIZEOF (handlers); h++)
{
enum iconv_ilseq_handler handler = handlers[h];
static const char input[] = "Rafa\305\202 Maszkowski"; /* Rafał Maszkowski */
- for (o = 0; o < 2; o++)
+ for (size_t o = 0; o < 2; o++)
{
size_t *offsets = (o ? new_offsets (strlen (input)) : NULL);
char *result = NULL;
ASSERT (result != NULL && memcmp (result, expected, strlen (expected)) == 0);
if (o)
{
- for (i = 0; i < 17; i++)
+ for (size_t i = 0; i < 17; i++)
ASSERT (offsets[i] == (i < 5 ? i :
i == 5 ? (size_t)(-1) :
i - 1));
ASSERT (result != NULL && memcmp (result, expected, strlen (expected)) == 0);
if (o)
{
- for (i = 0; i < 17; i++)
+ for (size_t i = 0; i < 17; i++)
ASSERT (offsets[i] == (i < 5 ? i :
i == 5 ? (size_t)(-1) :
i + 4));
}
/* Test conversion from UTF-8 to ISO-8859-1 with EINVAL. */
- for (h = 0; h < SIZEOF (handlers); h++)
+ for (size_t h = 0; h < SIZEOF (handlers); h++)
{
enum iconv_ilseq_handler handler = handlers[h];
static const char input[] = "\342";
- for (o = 0; o < 2; o++)
+ for (size_t o = 0; o < 2; o++)
{
size_t *offsets = (o ? new_offsets (strlen (input)) : NULL);
char *result = NULL;
/* ------------------------- Test str_iconveh() ------------------------- */
/* Test conversion from ISO-8859-2 to ISO-8859-1 with no errors. */
- for (h = 0; h < SIZEOF (handlers); h++)
+ for (size_t h = 0; h < SIZEOF (handlers); h++)
{
enum iconv_ilseq_handler handler = handlers[h];
static const char input[] = "\304rger mit b\366sen B\374bchen ohne Augenma\337";
}
/* Test conversion from ISO-8859-2 to ISO-8859-1 with EILSEQ. */
- for (h = 0; h < SIZEOF (handlers); h++)
+ for (size_t h = 0; h < SIZEOF (handlers); h++)
{
enum iconv_ilseq_handler handler = handlers[h];
static const char input[] = "Rafa\263 Maszkowski"; /* Rafał Maszkowski */
}
/* Test conversion from ISO-8859-1 to UTF-8 with no errors. */
- for (h = 0; h < SIZEOF (handlers); h++)
+ for (size_t h = 0; h < SIZEOF (handlers); h++)
{
enum iconv_ilseq_handler handler = handlers[h];
static const char input[] = "\304rger mit b\366sen B\374bchen ohne Augenma\337";
# if (defined _LIBICONV_VERSION && !(_LIBICONV_VERSION == 0x10b && defined __APPLE__)) || (defined __GLIBC__ && !defined __UCLIBC__)
/* Test conversion from ISO-8859-1 to GB18030 with no errors. */
- for (h = 0; h < SIZEOF (handlers); h++)
+ for (size_t h = 0; h < SIZEOF (handlers); h++)
{
enum iconv_ilseq_handler handler = handlers[h];
static const char input[] = "\304rger mit b\366sen B\374bchen ohne Augenma\337";
# endif
/* Test conversion from UTF-8 to ISO-8859-1 with no errors. */
- for (h = 0; h < SIZEOF (handlers); h++)
+ for (size_t h = 0; h < SIZEOF (handlers); h++)
{
enum iconv_ilseq_handler handler = handlers[h];
static const char input[] = "\303\204rger mit b\303\266sen B\303\274bchen ohne Augenma\303\237";
}
/* Test conversion from UTF-8 to ISO-8859-1 with EILSEQ. */
- for (h = 0; h < SIZEOF (handlers); h++)
+ for (size_t h = 0; h < SIZEOF (handlers); h++)
{
enum iconv_ilseq_handler handler = handlers[h];
static const char input[] = "Costs: 27 \342\202\254"; /* EURO SIGN */
}
/* Test conversion from UTF-8 to ISO-8859-1 with EINVAL. */
- for (h = 0; h < SIZEOF (handlers); h++)
+ for (size_t h = 0; h < SIZEOF (handlers); h++)
{
enum iconv_ilseq_handler handler = handlers[h];
static const char input[] = "\342";
#if HAVE_ICONV
static enum iconv_ilseq_handler handlers[] =
{ iconveh_error, iconveh_question_mark, iconveh_escape_sequence };
- size_t h;
- size_t o;
- size_t i;
/* Assume that iconv() supports at least the encodings ASCII, ISO-8859-1,
ISO-8859-2, and UTF-8. */
/* ------------------------- Test mem_iconveha() ------------------------- */
/* Test conversion from ISO-8859-2 to ISO-8859-1 with no errors. */
- for (h = 0; h < SIZEOF (handlers); h++)
+ for (size_t h = 0; h < SIZEOF (handlers); h++)
{
enum iconv_ilseq_handler handler = handlers[h];
static const char input[] = "\304rger mit b\366sen B\374bchen ohne Augenma\337";
static const char expected[] = "\304rger mit b\366sen B\374bchen ohne Augenma\337";
- for (o = 0; o < 2; o++)
+ for (size_t o = 0; o < 2; o++)
{
size_t *offsets = (o ? new_offsets (strlen (input)) : NULL);
char *result = NULL;
ASSERT (result != NULL && memcmp (result, expected, strlen (expected)) == 0);
if (o)
{
- for (i = 0; i < 37; i++)
+ for (size_t i = 0; i < 37; i++)
ASSERT (offsets[i] == i);
ASSERT (offsets[37] == MAGIC);
free (offsets);
}
/* Test conversion from ISO-8859-2 to ISO-8859-1 with EILSEQ. */
- for (h = 0; h < SIZEOF (handlers); h++)
+ for (size_t h = 0; h < SIZEOF (handlers); h++)
{
enum iconv_ilseq_handler handler = handlers[h];
static const char input[] = "Rafa\263 Maszkowski"; /* Rafał Maszkowski */
- for (o = 0; o < 2; o++)
+ for (size_t o = 0; o < 2; o++)
{
size_t *offsets = (o ? new_offsets (strlen (input)) : NULL);
char *result = NULL;
ASSERT (result != NULL && memcmp (result, expected, strlen (expected)) == 0);
if (o)
{
- for (i = 0; i < 16; i++)
+ for (size_t i = 0; i < 16; i++)
ASSERT (offsets[i] == i);
ASSERT (offsets[16] == MAGIC);
free (offsets);
ASSERT (result != NULL && memcmp (result, expected, strlen (expected)) == 0);
if (o)
{
- for (i = 0; i < 16; i++)
+ for (size_t i = 0; i < 16; i++)
ASSERT (offsets[i] == (i < 5 ? i :
i + 5));
ASSERT (offsets[16] == MAGIC);
}
/* Test conversion from ISO-8859-1 to UTF-8 with no errors. */
- for (h = 0; h < SIZEOF (handlers); h++)
+ for (size_t h = 0; h < SIZEOF (handlers); h++)
{
enum iconv_ilseq_handler handler = handlers[h];
static const char input[] = "\304rger mit b\366sen B\374bchen ohne Augenma\337";
static const char expected[] = "\303\204rger mit b\303\266sen B\303\274bchen ohne Augenma\303\237";
- for (o = 0; o < 2; o++)
+ for (size_t o = 0; o < 2; o++)
{
size_t *offsets = (o ? new_offsets (strlen (input)) : NULL);
char *result = NULL;
ASSERT (result != NULL && memcmp (result, expected, strlen (expected)) == 0);
if (o)
{
- for (i = 0; i < 37; i++)
+ for (size_t i = 0; i < 37; i++)
ASSERT (offsets[i] == (i < 1 ? i :
i < 12 ? i + 1 :
i < 18 ? i + 2 :
}
/* Test conversion from UTF-8 to ISO-8859-1 with no errors. */
- for (h = 0; h < SIZEOF (handlers); h++)
+ for (size_t h = 0; h < SIZEOF (handlers); h++)
{
enum iconv_ilseq_handler handler = handlers[h];
static const char input[] = "\303\204rger mit b\303\266sen B\303\274bchen ohne Augenma\303\237";
static const char expected[] = "\304rger mit b\366sen B\374bchen ohne Augenma\337";
- for (o = 0; o < 2; o++)
+ for (size_t o = 0; o < 2; o++)
{
size_t *offsets = (o ? new_offsets (strlen (input)) : NULL);
char *result = NULL;
ASSERT (result != NULL && memcmp (result, expected, strlen (expected)) == 0);
if (o)
{
- for (i = 0; i < 41; i++)
+ for (size_t i = 0; i < 41; i++)
ASSERT (offsets[i] == (i < 1 ? i :
i == 1 ? (size_t)(-1) :
i < 13 ? i - 1 :
}
/* Test conversion from UTF-8 to ISO-8859-1 with EILSEQ. */
- for (h = 0; h < SIZEOF (handlers); h++)
+ for (size_t h = 0; h < SIZEOF (handlers); h++)
{
enum iconv_ilseq_handler handler = handlers[h];
static const char input[] = "Rafa\305\202 Maszkowski"; /* Rafał Maszkowski */
- for (o = 0; o < 2; o++)
+ for (size_t o = 0; o < 2; o++)
{
size_t *offsets = (o ? new_offsets (strlen (input)) : NULL);
char *result = NULL;
ASSERT (result != NULL && memcmp (result, expected, strlen (expected)) == 0);
if (o)
{
- for (i = 0; i < 17; i++)
+ for (size_t i = 0; i < 17; i++)
ASSERT (offsets[i] == (i < 5 ? i :
i == 5 ? (size_t)(-1) :
i - 1));
ASSERT (result != NULL && memcmp (result, expected, strlen (expected)) == 0);
if (o)
{
- for (i = 0; i < 17; i++)
+ for (size_t i = 0; i < 17; i++)
ASSERT (offsets[i] == (i < 5 ? i :
i == 5 ? (size_t)(-1) :
i + 4));
}
/* Test conversion from UTF-8 to ISO-8859-1 with EINVAL. */
- for (h = 0; h < SIZEOF (handlers); h++)
+ for (size_t h = 0; h < SIZEOF (handlers); h++)
{
enum iconv_ilseq_handler handler = handlers[h];
static const char input[] = "\342";
- for (o = 0; o < 2; o++)
+ for (size_t o = 0; o < 2; o++)
{
size_t *offsets = (o ? new_offsets (strlen (input)) : NULL);
char *result = NULL;
if (iconv_supports_encoding ("ISO-2022-JP-2"))
{
/* Test conversions from autodetect_jp to UTF-8. */
- for (h = 0; h < SIZEOF (handlers); h++)
+ for (size_t h = 0; h < SIZEOF (handlers); h++)
{
enum iconv_ilseq_handler handler = handlers[h];
static const char input[] = "\244\263\244\363\244\313\244\301\244\317"; /* こんにちは in EUC-JP */
static const char expected[] = "\343\201\223\343\202\223\343\201\253\343\201\241\343\201\257"; /* こんにちは */
- for (o = 0; o < 2; o++)
+ for (size_t o = 0; o < 2; o++)
{
size_t *offsets = (o ? new_offsets (strlen (input)) : NULL);
char *result = NULL;
ASSERT (result != NULL && memcmp (result, expected, strlen (expected)) == 0);
if (o)
{
- for (i = 0; i < 10; i++)
+ for (size_t i = 0; i < 10; i++)
ASSERT (offsets[i] == ((i % 2) == 0 ? (i / 2) * 3 : (size_t)(-1)));
ASSERT (offsets[10] == MAGIC);
free (offsets);
free (result);
}
}
- for (h = 0; h < SIZEOF (handlers); h++)
+ for (size_t h = 0; h < SIZEOF (handlers); h++)
{
enum iconv_ilseq_handler handler = handlers[h];
static const char input[] = "\202\261\202\361\202\311\202\277\202\315"; /* こんにちは in Shift_JIS */
static const char expected[] = "\343\201\223\343\202\223\343\201\253\343\201\241\343\201\257"; /* こんにちは */
- for (o = 0; o < 2; o++)
+ for (size_t o = 0; o < 2; o++)
{
size_t *offsets = (o ? new_offsets (strlen (input)) : NULL);
char *result = NULL;
ASSERT (result != NULL && memcmp (result, expected, strlen (expected)) == 0);
if (o)
{
- for (i = 0; i < 10; i++)
+ for (size_t i = 0; i < 10; i++)
ASSERT (offsets[i] == ((i % 2) == 0 ? (i / 2) * 3 : (size_t)(-1)));
ASSERT (offsets[10] == MAGIC);
free (offsets);
free (result);
}
}
- for (h = 0; h < SIZEOF (handlers); h++)
+ for (size_t h = 0; h < SIZEOF (handlers); h++)
{
enum iconv_ilseq_handler handler = handlers[h];
static const char input[] = "\033$B$3$s$K$A$O\033(B"; /* こんにちは in ISO-2022-JP-2 */
static const char expected[] = "\343\201\223\343\202\223\343\201\253\343\201\241\343\201\257"; /* こんにちは */
- for (o = 0; o < 2; o++)
+ for (size_t o = 0; o < 2; o++)
{
size_t *offsets = (o ? new_offsets (strlen (input)) : NULL);
char *result = NULL;
ASSERT (result != NULL && memcmp (result, expected, strlen (expected)) == 0);
if (o)
{
- for (i = 0; i < 16; i++)
+ for (size_t i = 0; i < 16; i++)
ASSERT (offsets[i] == (i == 0 ? 0 :
i == 5 ? 3 :
i == 7 ? 6 :
# if (((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 2) || __GLIBC__ > 2) && !defined __UCLIBC__) || (_LIBICONV_VERSION >= 0x0105 && !(_LIBICONV_VERSION == 0x10b && defined __APPLE__))
/* Test conversion from UTF-8 to ISO-8859-1 with transliteration. */
- for (h = 0; h < SIZEOF (handlers); h++)
+ for (size_t h = 0; h < SIZEOF (handlers); h++)
{
enum iconv_ilseq_handler handler = handlers[h];
static const char input[] = "Costs: 27 \342\202\254"; /* EURO SIGN */
static const char expected[] = "Costs: 27 EUR";
- for (o = 0; o < 2; o++)
+ for (size_t o = 0; o < 2; o++)
{
size_t *offsets = (o ? new_offsets (strlen (input)) : NULL);
char *result = NULL;
ASSERT (result != NULL && memcmp (result, expected, strlen (expected)) == 0);
if (o)
{
- for (i = 0; i < 13; i++)
+ for (size_t i = 0; i < 13; i++)
ASSERT (offsets[i] == (i < 11 ? i : (size_t)(-1)));
ASSERT (offsets[13] == MAGIC);
free (offsets);
/* ------------------------- Test str_iconveha() ------------------------- */
/* Test conversion from ISO-8859-2 to ISO-8859-1 with no errors. */
- for (h = 0; h < SIZEOF (handlers); h++)
+ for (size_t h = 0; h < SIZEOF (handlers); h++)
{
enum iconv_ilseq_handler handler = handlers[h];
static const char input[] = "\304rger mit b\366sen B\374bchen ohne Augenma\337";
}
/* Test conversion from ISO-8859-2 to ISO-8859-1 with EILSEQ. */
- for (h = 0; h < SIZEOF (handlers); h++)
+ for (size_t h = 0; h < SIZEOF (handlers); h++)
{
enum iconv_ilseq_handler handler = handlers[h];
static const char input[] = "Rafa\263 Maszkowski"; /* Rafał Maszkowski */
}
/* Test conversion from ISO-8859-1 to UTF-8 with no errors. */
- for (h = 0; h < SIZEOF (handlers); h++)
+ for (size_t h = 0; h < SIZEOF (handlers); h++)
{
enum iconv_ilseq_handler handler = handlers[h];
static const char input[] = "\304rger mit b\366sen B\374bchen ohne Augenma\337";
}
/* Test conversion from UTF-8 to ISO-8859-1 with no errors. */
- for (h = 0; h < SIZEOF (handlers); h++)
+ for (size_t h = 0; h < SIZEOF (handlers); h++)
{
enum iconv_ilseq_handler handler = handlers[h];
static const char input[] = "\303\204rger mit b\303\266sen B\303\274bchen ohne Augenma\303\237";
}
/* Test conversion from UTF-8 to ISO-8859-1 with EILSEQ. */
- for (h = 0; h < SIZEOF (handlers); h++)
+ for (size_t h = 0; h < SIZEOF (handlers); h++)
{
enum iconv_ilseq_handler handler = handlers[h];
static const char input[] = "Costs: 27 \342\202\254"; /* EURO SIGN */
}
/* Test conversion from UTF-8 to ISO-8859-1 with EINVAL. */
- for (h = 0; h < SIZEOF (handlers); h++)
+ for (size_t h = 0; h < SIZEOF (handlers); h++)
{
enum iconv_ilseq_handler handler = handlers[h];
static const char input[] = "\342";
if (iconv_supports_encoding ("ISO-2022-JP-2"))
{
/* Test conversions from autodetect_jp to UTF-8. */
- for (h = 0; h < SIZEOF (handlers); h++)
+ for (size_t h = 0; h < SIZEOF (handlers); h++)
{
enum iconv_ilseq_handler handler = handlers[h];
static const char input[] = "\244\263\244\363\244\313\244\301\244\317"; /* こんにちは in EUC-JP */
ASSERT (strcmp (result, expected) == 0);
free (result);
}
- for (h = 0; h < SIZEOF (handlers); h++)
+ for (size_t h = 0; h < SIZEOF (handlers); h++)
{
enum iconv_ilseq_handler handler = handlers[h];
static const char input[] = "\202\261\202\361\202\311\202\277\202\315"; /* こんにちは in Shift_JIS */
ASSERT (strcmp (result, expected) == 0);
free (result);
}
- for (h = 0; h < SIZEOF (handlers); h++)
+ for (size_t h = 0; h < SIZEOF (handlers); h++)
{
enum iconv_ilseq_handler handler = handlers[h];
static const char input[] = "\033$B$3$s$K$A$O\033(B"; /* こんにちは in ISO-2022-JP-2 */
# if (((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 2) || __GLIBC__ > 2) && !defined __UCLIBC__) || (_LIBICONV_VERSION >= 0x0105 && !(_LIBICONV_VERSION == 0x10b && defined __APPLE__))
/* Test conversion from UTF-8 to ISO-8859-1 with transliteration. */
- for (h = 0; h < SIZEOF (handlers); h++)
+ for (size_t h = 0; h < SIZEOF (handlers); h++)
{
enum iconv_ilseq_handler handler = handlers[h];
static const char input[] = "Costs: 27 \342\202\254"; /* EURO SIGN */
int
main (void)
{
- size_t i;
char *page_boundary = (char *) zerosize_ptr ();
if (!page_boundary)
{
ASSERT (strnlen ("", 0x100000) == 0);
/* Memory fence and alignment testing. */
- for (i = 0; i < 512; i++)
+ for (size_t i = 0; i < 512; i++)
{
char *start = page_boundary - i;
size_t j = i;
"with_multilib_list\n";
size_t h_len = strlen (h);
char *haystack = malloc (h_len + 1);
- size_t i;
ASSERT (haystack);
- for (i = 0; i < h_len - strlen (needle); i++)
+ for (size_t i = 0; i < h_len - strlen (needle); i++)
{
const char *p;
memcpy (haystack, h, h_len + 1);
/* Check the system_quote_length, system_quote_copy, system_quote
functions. */
{
- int c;
-
/* Empty argument. */
check_one (interpreter, prog, "");
check_one (interpreter, prog, "%PATH%");
/* All other characters don't need quoting. */
- for (c = 1; c <= UCHAR_MAX; c++)
+ for (int c = 1; c <= UCHAR_MAX; c++)
if (strchr ("\t\n\r !\"#$&'()*;<=>?^[\\]`{|}~", c) == NULL)
{
char s[5];
#ifdef WINDOWS_NATIVE
/* Make PROG suitable for native Windows system calls and cmd.exe:
Replace '/' with '\\'. */
- {
- char *p;
- for (p = prog; *p != '\0'; p++)
- if (*p == '/')
- *p = '\\';
- }
+ for (char *p = prog; *p != '\0'; p++)
+ if (*p == '/')
+ *p = '\\';
#endif
#ifdef WINDOWS_NATIVE
{ /* This test would fail on AIX 7.1. */
ptrdiff_t retval =
my_szprintf (result, "%.4000d %d", 1234567, 99);
- size_t i;
- for (i = 0; i < 4000 - 7; i++)
+ for (size_t i = 0; i < 4000 - 7; i++)
ASSERT (result[i] == '0');
ASSERT (strcmp (result + 4000 - 7, "1234567 99") == 0);
ASSERT (retval == strlen (result));
worker_thread (void *arg)
{
unsigned int id = (unsigned int) (uintptr_t) arg;
- int i, j, repeat;
unsigned int *values[KEYS_COUNT] = { &value0, &value1, &value2, &value3 };
dbgprintf ("Worker %p started\n", thrd_current_pointer ());
/* Initialize the per-thread storage. */
dbgprintf ("Worker %p before first assignment\n", thrd_current_pointer ());
- for (i = 0; i < KEYS_COUNT; i++)
+ for (int i = 0; i < KEYS_COUNT; i++)
{
*values[i] = (((unsigned long) random () >> 3) % 1000000) * THREAD_COUNT + id;
/* Hopefully no arithmetic overflow. */
perhaps_yield ();
/* Shuffle around the pointers. */
- for (repeat = REPEAT_COUNT; repeat > 0; repeat--)
+ for (int repeat = REPEAT_COUNT; repeat > 0; repeat--)
{
dbgprintf ("Worker %p doing value swapping\n", thrd_current_pointer ());
- i = ((unsigned long) random () >> 3) % KEYS_COUNT;
- j = ((unsigned long) random () >> 3) % KEYS_COUNT;
+ int i = ((unsigned long) random () >> 3) % KEYS_COUNT;
+ int j = ((unsigned long) random () >> 3) % KEYS_COUNT;
if (i != j)
{
unsigned int vi = *values[i];
/* Verify that all the values are from this thread. */
dbgprintf ("Worker %p before final verify\n", thrd_current_pointer ());
- for (i = 0; i < KEYS_COUNT; i++)
+ for (int i = 0; i < KEYS_COUNT; i++)
if ((*values[i] % THREAD_COUNT) != id)
abort ();
dbgprintf ("Worker %p after final verify\n", thrd_current_pointer ());
static void
test_thread_local (void)
{
- int pass, i;
-
- for (pass = 0; pass < 2; pass++)
+ for (int pass = 0; pass < 2; pass++)
{
thrd_t threads[THREAD_COUNT];
/* Spawn the threads. */
- for (i = 0; i < THREAD_COUNT; i++)
+ for (int i = 0; i < THREAD_COUNT; i++)
ASSERT (thrd_create (&threads[i], worker_thread, (void *) (uintptr_t) i)
== thrd_success);
/* Wait for the threads to terminate. */
- for (i = 0; i < THREAD_COUNT; i++)
+ for (int i = 0; i < THREAD_COUNT; i++)
ASSERT (thrd_join (threads[i], NULL) == thrd_success);
}
}
{
size_t size = atoi (argv[1]);
double *base;
- size_t i;
base = malloc (size * sizeof (double));
- for (i = 0; i < size; i++)
+ for (size_t i = 0; i < size; i++)
base[i] = i * i;
qsort (base, size, sizeof (double), doublecmp);
int
main (void)
{
- int i, j, k;
struct timespec test[nprototypes + 1];
int ntests;
int computed_hz = 1;
test[0] = make_timespec (TYPE_MINIMUM (time_t), -1);
ntests = 1;
- for (i = 0; i < nprototypes; i++)
+ for (int i = 0; i < nprototypes; i++)
{
int s = prototype[i].s;
if (TYPE_SIGNED (time_t) || 0 <= s)
}
}
- for (i = 0; i < LOG10_TIMESPEC_HZ; i++)
+ for (int i = 0; i < LOG10_TIMESPEC_HZ; i++)
computed_hz *= 10;
ASSERT (computed_hz == TIMESPEC_HZ);
- for (i = 0; i < ntests; i++)
+ for (int i = 0; i < ntests; i++)
{
struct timespec a = test[i];
ASSERT (sign (timespec_sign (a)) == cmp (a, make_timespec (0, 0)));
if (valid (a))
- for (j = 0; j < ntests; j++)
+ for (int j = 0; j < ntests; j++)
{
struct timespec b = test[j];
if (valid (b))
ASSERT (eq (a, timespec_sub (sum, b)));
ASSERT (eq (b, timespec_sub (sum, a)));
- for (k = 0; k < ntests; k++)
+ for (int k = 0; k < ntests; k++)
{
struct timespec c = test[k];
if (valid (c))
worker_thread (void *arg)
{
unsigned int id = (unsigned int) (uintptr_t) arg;
- int i, j, repeat;
unsigned int values[KEYS_COUNT];
dbgprintf ("Worker %p started\n", gl_thread_self_pointer ());
/* Initialize the per-thread storage. */
- for (i = 0; i < KEYS_COUNT; i++)
+ for (int i = 0; i < KEYS_COUNT; i++)
{
values[i] = (((unsigned long) random () >> 3) % 1000000) * THREAD_COUNT + id;
/* Hopefully no arithmetic overflow. */
/* Verify that the initial value is NULL. */
dbgprintf ("Worker %p before initial verify\n", gl_thread_self_pointer ());
- for (i = 0; i < KEYS_COUNT; i++)
+ for (int i = 0; i < KEYS_COUNT; i++)
if (gl_tls_get (mykeys[i]) != NULL)
abort ();
dbgprintf ("Worker %p after initial verify\n", gl_thread_self_pointer ());
/* Initialize the per-thread storage. */
dbgprintf ("Worker %p before first tls_set\n", gl_thread_self_pointer ());
- for (i = 0; i < KEYS_COUNT; i++)
+ for (int i = 0; i < KEYS_COUNT; i++)
{
unsigned int *ptr = (unsigned int *) malloc (sizeof (unsigned int));
*ptr = values[i];
perhaps_yield ();
/* Shuffle around the pointers. */
- for (repeat = REPEAT_COUNT; repeat > 0; repeat--)
+ for (int repeat = REPEAT_COUNT; repeat > 0; repeat--)
{
dbgprintf ("Worker %p doing value swapping\n", gl_thread_self_pointer ());
- i = ((unsigned long) random () >> 3) % KEYS_COUNT;
- j = ((unsigned long) random () >> 3) % KEYS_COUNT;
+ int i = ((unsigned long) random () >> 3) % KEYS_COUNT;
+ int j = ((unsigned long) random () >> 3) % KEYS_COUNT;
if (i != j)
{
void *vi = gl_tls_get (mykeys[i]);
/* Verify that all the values are from this thread. */
dbgprintf ("Worker %p before final verify\n", gl_thread_self_pointer ());
- for (i = 0; i < KEYS_COUNT; i++)
+ for (int i = 0; i < KEYS_COUNT; i++)
if ((*(unsigned int *) gl_tls_get (mykeys[i]) % THREAD_COUNT) != id)
abort ();
dbgprintf ("Worker %p after final verify\n", gl_thread_self_pointer ());
static void
test_tls (void)
{
- int pass, i;
-
- for (pass = 0; pass < 2; pass++)
+ for (int pass = 0; pass < 2; pass++)
{
gl_thread_t threads[THREAD_COUNT];
if (pass == 0)
- for (i = 0; i < KEYS_COUNT; i++)
+ for (int i = 0; i < KEYS_COUNT; i++)
gl_tls_key_init (mykeys[i], free);
else
- for (i = KEYS_COUNT - 1; i >= 0; i--)
+ for (int i = KEYS_COUNT - 1; i >= 0; i--)
gl_tls_key_init (mykeys[i], free);
/* Spawn the threads. */
- for (i = 0; i < THREAD_COUNT; i++)
+ for (int i = 0; i < THREAD_COUNT; i++)
threads[i] = gl_thread_create (worker_thread, (void *) (uintptr_t) i);
/* Wait for the threads to terminate. */
- for (i = 0; i < THREAD_COUNT; i++)
+ for (int i = 0; i < THREAD_COUNT; i++)
gl_thread_join (threads[i], NULL);
- for (i = 0; i < KEYS_COUNT; i++)
+ for (int i = 0; i < KEYS_COUNT; i++)
gl_tls_key_destroy (mykeys[i]);
}
}
{
unsigned int id = (unsigned int) (uintptr_t) arg;
gl_tls_key_t *keys = dtorcheck_keys[id]; /* an array of KEYS_COUNT keys */
- int i;
- for (i = 0; i < KEYS_COUNT; i++)
+ for (int i = 0; i < KEYS_COUNT; i++)
gl_tls_key_init (keys[i], destructor_table[i]);
- for (i = 0; i < KEYS_COUNT; i++)
+ for (int i = 0; i < KEYS_COUNT; i++)
gl_tls_set (keys[i], (void *) (uintptr_t) (10 * id + i + 1));
return NULL;
test_tls_dtorcheck1 (void)
{
gl_thread_t threads[THREAD_COUNT];
- unsigned int id;
- int i;
uintptr_t expected_sum;
sum = 0;
/* Spawn the threads. */
- for (id = 0; id < THREAD_COUNT; id++)
+ for (unsigned int id = 0; id < THREAD_COUNT; id++)
threads[id] = gl_thread_create (dtorcheck1_thread, (void *) (uintptr_t) id);
/* Wait for the threads to terminate. */
- for (id = 0; id < THREAD_COUNT; id++)
+ for (unsigned int id = 0; id < THREAD_COUNT; id++)
gl_thread_join (threads[id], NULL);
/* Clean up the keys. */
- for (id = 0; id < THREAD_COUNT; id++)
- for (i = 0; i < KEYS_COUNT; i++)
+ for (unsigned int id = 0; id < THREAD_COUNT; id++)
+ for (int i = 0; i < KEYS_COUNT; i++)
gl_tls_key_destroy (dtorcheck_keys[id][i]);
/* Check that the destructor was invoked for each key. */
{
unsigned int id = (unsigned int) (uintptr_t) arg;
gl_tls_key_t *keys = dtorcheck_keys[id]; /* an array of KEYS_COUNT keys */
- int i;
- for (i = 0; i < KEYS_COUNT; i++)
+ for (int i = 0; i < KEYS_COUNT; i++)
gl_tls_key_init (keys[i], destructor_table[id]);
- for (i = 0; i < KEYS_COUNT; i++)
+ for (int i = 0; i < KEYS_COUNT; i++)
gl_tls_set (keys[i], (void *) (uintptr_t) (10 * i + id + 1));
return NULL;
test_tls_dtorcheck2 (void)
{
gl_thread_t threads[THREAD_COUNT];
- unsigned int id;
- int i;
uintptr_t expected_sum;
sum = 0;
/* Spawn the threads. */
- for (id = 0; id < THREAD_COUNT; id++)
+ for (unsigned int id = 0; id < THREAD_COUNT; id++)
threads[id] = gl_thread_create (dtorcheck2_thread, (void *) (uintptr_t) id);
/* Wait for the threads to terminate. */
- for (id = 0; id < THREAD_COUNT; id++)
+ for (unsigned int id = 0; id < THREAD_COUNT; id++)
gl_thread_join (threads[id], NULL);
/* Clean up the keys. */
- for (id = 0; id < THREAD_COUNT; id++)
- for (i = 0; i < KEYS_COUNT; i++)
+ for (unsigned int id = 0; id < THREAD_COUNT; id++)
+ for (int i = 0; i < KEYS_COUNT; i++)
gl_tls_key_destroy (dtorcheck_keys[id][i]);
/* Check that the destructor was invoked for each key. */
{
unsigned int id = (unsigned int) (uintptr_t) arg;
gl_tls_key_t *keys = racecheck_keys[id]; /* an array of KEYS_COUNT keys */
- int repeat;
- int i;
dbgprintf ("Worker %p started\n", gl_thread_self_pointer ());
- for (i = 0; i < KEYS_COUNT; i++)
+ for (int i = 0; i < KEYS_COUNT; i++)
{
gl_tls_key_init (keys[i], destructor_table[i]);
gl_tls_set (keys[i], (void *) (uintptr_t) (10 * id + i + 1));
}
- for (repeat = REPEAT_COUNT; repeat > 0; repeat--)
+ for (int repeat = REPEAT_COUNT; repeat > 0; repeat--)
{
- i = ((unsigned long) random () >> 3) % KEYS_COUNT;
+ int i = ((unsigned long) random () >> 3) % KEYS_COUNT;
dbgprintf ("Worker %p reallocating key %d\n", gl_thread_self_pointer (), i);
gl_tls_key_destroy (keys[i]);
gl_tls_key_init (keys[i], destructor_table[i]);
test_tls_racecheck (void)
{
gl_thread_t threads[THREAD_COUNT];
- unsigned int id;
- int i;
uintptr_t expected_sum;
sum = 0;
/* Spawn the threads. */
- for (id = 0; id < THREAD_COUNT; id++)
+ for (unsigned int id = 0; id < THREAD_COUNT; id++)
threads[id] = gl_thread_create (racecheck_thread, (void *) (uintptr_t) id);
/* Wait for the threads to terminate. */
- for (id = 0; id < THREAD_COUNT; id++)
+ for (unsigned int id = 0; id < THREAD_COUNT; id++)
gl_thread_join (threads[id], NULL);
/* Clean up the keys. */
- for (id = 0; id < THREAD_COUNT; id++)
- for (i = 0; i < KEYS_COUNT; i++)
+ for (unsigned int id = 0; id < THREAD_COUNT; id++)
+ for (int i = 0; i < KEYS_COUNT; i++)
gl_tls_key_destroy (racecheck_keys[id][i]);
/* Check that the destructor was invoked for each key. */
the uppercase characters include only the ASCII A ... Z characters,
and the corresponding characters a ... z are lowercase.
*/
- {
- int c;
-
- for (c = 0; c < 0x100; c++)
- switch (c)
- {
- case '\t': case '\v': case '\f':
- case ' ': case '!': case '"': case '#': case '%':
- case '&': case '\'': case '(': case ')': case '*':
- case '+': case ',': case '-': case '.': case '/':
- case '0': case '1': case '2': case '3': case '4':
- case '5': case '6': case '7': case '8': case '9':
- case ':': case ';': case '<': case '=': case '>':
- case '?':
- case 'A': case 'B': case 'C': case 'D': case 'E':
- case 'F': case 'G': case 'H': case 'I': case 'J':
- case 'K': case 'L': case 'M': case 'N': case 'O':
- case 'P': case 'Q': case 'R': case 'S': case 'T':
- case 'U': case 'V': case 'W': case 'X': case 'Y':
- case 'Z':
- case '[': case '\\': case ']': case '^': case '_':
- case 'a': case 'b': case 'c': case 'd': case 'e':
- case 'f': case 'g': case 'h': case 'i': case 'j':
- case 'k': case 'l': case 'm': case 'n': case 'o':
- case 'p': case 'q': case 'r': case 's': case 't':
- case 'u': case 'v': case 'w': case 'x': case 'y':
- case 'z': case '{': case '|': case '}': case '~':
- /* c is in the ISO C "basic character set". */
- tc = tolower_l ((unsigned char) c, locale);
- switch (c)
- {
- case 'A': case 'B': case 'C': case 'D': case 'E':
- case 'F': case 'G': case 'H': case 'I': case 'J':
- case 'K': case 'L': case 'M': case 'N': case 'O':
- case 'P': case 'Q': case 'R': case 'S': case 'T':
- case 'U': case 'V': case 'W': case 'X': case 'Y':
- case 'Z':
- ASSERT (tc == (unsigned char) c - 'A' + 'a');
- break;
- default:
- ASSERT (tc == c);
- break;
- }
- break;
- }
- }
+ for (int c = 0; c < 0x100; c++)
+ switch (c)
+ {
+ case '\t': case '\v': case '\f':
+ case ' ': case '!': case '"': case '#': case '%':
+ case '&': case '\'': case '(': case ')': case '*':
+ case '+': case ',': case '-': case '.': case '/':
+ case '0': case '1': case '2': case '3': case '4':
+ case '5': case '6': case '7': case '8': case '9':
+ case ':': case ';': case '<': case '=': case '>':
+ case '?':
+ case 'A': case 'B': case 'C': case 'D': case 'E':
+ case 'F': case 'G': case 'H': case 'I': case 'J':
+ case 'K': case 'L': case 'M': case 'N': case 'O':
+ case 'P': case 'Q': case 'R': case 'S': case 'T':
+ case 'U': case 'V': case 'W': case 'X': case 'Y':
+ case 'Z':
+ case '[': case '\\': case ']': case '^': case '_':
+ case 'a': case 'b': case 'c': case 'd': case 'e':
+ case 'f': case 'g': case 'h': case 'i': case 'j':
+ case 'k': case 'l': case 'm': case 'n': case 'o':
+ case 'p': case 'q': case 'r': case 's': case 't':
+ case 'u': case 'v': case 'w': case 'x': case 'y':
+ case 'z': case '{': case '|': case '}': case '~':
+ /* c is in the ISO C "basic character set". */
+ tc = tolower_l ((unsigned char) c, locale);
+ switch (c)
+ {
+ case 'A': case 'B': case 'C': case 'D': case 'E':
+ case 'F': case 'G': case 'H': case 'I': case 'J':
+ case 'K': case 'L': case 'M': case 'N': case 'O':
+ case 'P': case 'Q': case 'R': case 'S': case 'T':
+ case 'U': case 'V': case 'W': case 'X': case 'Y':
+ case 'Z':
+ ASSERT (tc == (unsigned char) c - 'A' + 'a');
+ break;
+ default:
+ ASSERT (tc == c);
+ break;
+ }
+ break;
+ }
}
int
the lowercase characters include only the ASCII a ... z characters,
and the corresponding characters A ... Z are uppercase.
*/
- {
- int c;
-
- for (c = 0; c < 0x100; c++)
- switch (c)
- {
- case '\t': case '\v': case '\f':
- case ' ': case '!': case '"': case '#': case '%':
- case '&': case '\'': case '(': case ')': case '*':
- case '+': case ',': case '-': case '.': case '/':
- case '0': case '1': case '2': case '3': case '4':
- case '5': case '6': case '7': case '8': case '9':
- case ':': case ';': case '<': case '=': case '>':
- case '?':
- case 'A': case 'B': case 'C': case 'D': case 'E':
- case 'F': case 'G': case 'H': case 'I': case 'J':
- case 'K': case 'L': case 'M': case 'N': case 'O':
- case 'P': case 'Q': case 'R': case 'S': case 'T':
- case 'U': case 'V': case 'W': case 'X': case 'Y':
- case 'Z':
- case '[': case '\\': case ']': case '^': case '_':
- case 'a': case 'b': case 'c': case 'd': case 'e':
- case 'f': case 'g': case 'h': case 'i': case 'j':
- case 'k': case 'l': case 'm': case 'n': case 'o':
- case 'p': case 'q': case 'r': case 's': case 't':
- case 'u': case 'v': case 'w': case 'x': case 'y':
- case 'z': case '{': case '|': case '}': case '~':
- /* c is in the ISO C "basic character set". */
- tc = toupper_l ((unsigned char) c, locale);
- switch (c)
- {
- case 'a': case 'b': case 'c': case 'd': case 'e':
- case 'f': case 'g': case 'h': case 'i': case 'j':
- case 'k': case 'l': case 'm': case 'n': case 'o':
- case 'p': case 'q': case 'r': case 's': case 't':
- case 'u': case 'v': case 'w': case 'x': case 'y':
- case 'z':
- ASSERT (tc == (unsigned char) c - 'a' + 'A');
- break;
- default:
- ASSERT (tc == c);
- break;
- }
- break;
- }
- }
+ for (int c = 0; c < 0x100; c++)
+ switch (c)
+ {
+ case '\t': case '\v': case '\f':
+ case ' ': case '!': case '"': case '#': case '%':
+ case '&': case '\'': case '(': case ')': case '*':
+ case '+': case ',': case '-': case '.': case '/':
+ case '0': case '1': case '2': case '3': case '4':
+ case '5': case '6': case '7': case '8': case '9':
+ case ':': case ';': case '<': case '=': case '>':
+ case '?':
+ case 'A': case 'B': case 'C': case 'D': case 'E':
+ case 'F': case 'G': case 'H': case 'I': case 'J':
+ case 'K': case 'L': case 'M': case 'N': case 'O':
+ case 'P': case 'Q': case 'R': case 'S': case 'T':
+ case 'U': case 'V': case 'W': case 'X': case 'Y':
+ case 'Z':
+ case '[': case '\\': case ']': case '^': case '_':
+ case 'a': case 'b': case 'c': case 'd': case 'e':
+ case 'f': case 'g': case 'h': case 'i': case 'j':
+ case 'k': case 'l': case 'm': case 'n': case 'o':
+ case 'p': case 'q': case 'r': case 's': case 't':
+ case 'u': case 'v': case 'w': case 'x': case 'y':
+ case 'z': case '{': case '|': case '}': case '~':
+ /* c is in the ISO C "basic character set". */
+ tc = toupper_l ((unsigned char) c, locale);
+ switch (c)
+ {
+ case 'a': case 'b': case 'c': case 'd': case 'e':
+ case 'f': case 'g': case 'h': case 'i': case 'j':
+ case 'k': case 'l': case 'm': case 'n': case 'o':
+ case 'p': case 'q': case 'r': case 's': case 't':
+ case 'u': case 'v': case 'w': case 'x': case 'y':
+ case 'z':
+ ASSERT (tc == (unsigned char) c - 'a' + 'A');
+ break;
+ default:
+ ASSERT (tc == c);
+ break;
+ }
+ break;
+ }
}
int
int
main ()
{
- unsigned int highbits;
- unsigned int lowbits;
int error = 0;
- for (highbits = 0; highbits < (1 << NUM_HIGHBITS); highbits++)
- for (lowbits = 0; lowbits < (1 << NUM_LOWBITS); lowbits++)
+ for (unsigned int highbits = 0; highbits < (1 << NUM_HIGHBITS); highbits++)
+ for (unsigned int lowbits = 0; lowbits < (1 << NUM_LOWBITS); lowbits++)
{
/* Combine highbits and lowbits into a floating-point number,
sign-extending the lowbits to 32-NUM_HIGHBITS bits. */
int
main ()
{
- unsigned int highbits;
- unsigned int lowbits;
int error = 0;
- for (highbits = 0; highbits < (1 << NUM_HIGHBITS); highbits++)
- for (lowbits = 0; lowbits < (1 << NUM_LOWBITS); lowbits++)
+ for (unsigned int highbits = 0; highbits < (1 << NUM_HIGHBITS); highbits++)
+ for (unsigned int lowbits = 0; lowbits < (1 << NUM_LOWBITS); lowbits++)
{
/* Combine highbits and lowbits into a floating-point number,
sign-extending the lowbits to 32-NUM_HIGHBITS bits. */
static void
memfry (int *string)
{
- int i;
-
- for (i = 0; i < SIZE; ++i)
+ for (int i = 0; i < SIZE; ++i)
{
int32_t j;
int c;
static void
walk_tree (void *root, int expected_count)
{
- int i;
-
memset (z, 0, sizeof z);
max_depth = 0;
twalk (root, walk_action);
- for (i = 0; i < expected_count; ++i)
+ for (int i = 0; i < expected_count; ++i)
if (z[i] != 1)
{
fputs ("Node was not visited.\n", stdout);
static void
mangle_tree (enum order how, enum action what, void **root, int lag)
{
- int i;
-
if (how == randomorder)
{
- for (i = 0; i < SIZE; ++i)
+ for (int i = 0; i < SIZE; ++i)
y[i] = i;
memfry (y);
}
- for (i = 0; i < SIZE + lag; ++i)
+ for (int i = 0; i < SIZE + lag; ++i)
{
void *elem;
int j, k;
{
int total_error = 0;
void *root = NULL;
- int i, j;
#if HAVE_INITSTATE
static char state[8] = { 1, 2, 3, 4, 5, 6, 7, 8 };
initstate (SEED, state, 8);
#endif
- for (i = 0; i < SIZE; ++i)
+ for (int i = 0; i < SIZE; ++i)
x[i] = i;
/* Do this loop several times to get different permutations for the
random case. */
fputs ("Series I\n", stdout);
- for (i = 0; i < PASSES; ++i)
+ for (int i = 0; i < PASSES; ++i)
{
fprintf (stdout, "Pass %d... ", i + 1);
fflush (stdout);
walk_tree (root, SIZE);
mangle_tree (randomorder, delete, &root, 0);
- for (j = 1; j < SIZE; j *= 2)
+ for (int j = 1; j < SIZE; j *= 2)
{
mangle_tree (randomorder, build_and_del, &root, j);
}
}
fputs ("Series II\n", stdout);
- for (i = 1; i < SIZE; i *= 2)
+ for (int i = 1; i < SIZE; i *= 2)
{
fprintf (stdout, "For size %d... ", i);
fflush (stdout);
worker_thread (void *arg)
{
unsigned int id = (unsigned int) (uintptr_t) arg;
- int i, j, repeat;
unsigned int values[KEYS_COUNT];
dbgprintf ("Worker %p started\n", thrd_current_pointer ());
/* Initialize the per-thread storage. */
- for (i = 0; i < KEYS_COUNT; i++)
+ for (int i = 0; i < KEYS_COUNT; i++)
{
values[i] = (((unsigned long) random () >> 3) % 1000000) * THREAD_COUNT + id;
/* Hopefully no arithmetic overflow. */
/* Verify that the initial value is NULL. */
dbgprintf ("Worker %p before initial verify\n", thrd_current_pointer ());
- for (i = 0; i < KEYS_COUNT; i++)
+ for (int i = 0; i < KEYS_COUNT; i++)
if (tss_get (mykeys[i]) != NULL)
abort ();
dbgprintf ("Worker %p after initial verify\n", thrd_current_pointer ());
/* Initialize the per-thread storage. */
dbgprintf ("Worker %p before first tss_set\n", thrd_current_pointer ());
- for (i = 0; i < KEYS_COUNT; i++)
+ for (int i = 0; i < KEYS_COUNT; i++)
{
unsigned int *ptr = (unsigned int *) malloc (sizeof (unsigned int));
*ptr = values[i];
perhaps_yield ();
/* Shuffle around the pointers. */
- for (repeat = REPEAT_COUNT; repeat > 0; repeat--)
+ for (int repeat = REPEAT_COUNT; repeat > 0; repeat--)
{
dbgprintf ("Worker %p doing value swapping\n", thrd_current_pointer ());
- i = ((unsigned long) random () >> 3) % KEYS_COUNT;
- j = ((unsigned long) random () >> 3) % KEYS_COUNT;
+ int i = ((unsigned long) random () >> 3) % KEYS_COUNT;
+ int j = ((unsigned long) random () >> 3) % KEYS_COUNT;
if (i != j)
{
void *vi = tss_get (mykeys[i]);
/* Verify that all the values are from this thread. */
dbgprintf ("Worker %p before final verify\n", thrd_current_pointer ());
- for (i = 0; i < KEYS_COUNT; i++)
+ for (int i = 0; i < KEYS_COUNT; i++)
if ((*(unsigned int *) tss_get (mykeys[i]) % THREAD_COUNT) != id)
abort ();
dbgprintf ("Worker %p after final verify\n", thrd_current_pointer ());
static void
test_tss (void)
{
- int pass, i;
-
- for (pass = 0; pass < 2; pass++)
+ for (int pass = 0; pass < 2; pass++)
{
thrd_t threads[THREAD_COUNT];
if (pass == 0)
- for (i = 0; i < KEYS_COUNT; i++)
+ for (int i = 0; i < KEYS_COUNT; i++)
ASSERT (tss_create (&mykeys[i], free) == thrd_success);
else
- for (i = KEYS_COUNT - 1; i >= 0; i--)
+ for (int i = KEYS_COUNT - 1; i >= 0; i--)
ASSERT (tss_create (&mykeys[i], free) == thrd_success);
/* Spawn the threads. */
- for (i = 0; i < THREAD_COUNT; i++)
+ for (int i = 0; i < THREAD_COUNT; i++)
ASSERT (thrd_create (&threads[i], worker_thread, (void *) (uintptr_t) i)
== thrd_success);
/* Wait for the threads to terminate. */
- for (i = 0; i < THREAD_COUNT; i++)
+ for (int i = 0; i < THREAD_COUNT; i++)
ASSERT (thrd_join (threads[i], NULL) == thrd_success);
- for (i = 0; i < KEYS_COUNT; i++)
+ for (int i = 0; i < KEYS_COUNT; i++)
tss_delete (mykeys[i]);
}
}
{
unsigned int id = (unsigned int) (uintptr_t) arg;
tss_t *keys = dtorcheck_keys[id]; /* an array of KEYS_COUNT keys */
- int i;
- for (i = 0; i < KEYS_COUNT; i++)
+ for (int i = 0; i < KEYS_COUNT; i++)
ASSERT (tss_create (&keys[i], destructor_table[i]) == thrd_success);
- for (i = 0; i < KEYS_COUNT; i++)
+ for (int i = 0; i < KEYS_COUNT; i++)
ASSERT (tss_set (keys[i], (void *) (uintptr_t) (10 * id + i + 1))
== thrd_success);
test_tss_dtorcheck1 (void)
{
thrd_t threads[THREAD_COUNT];
- unsigned int id;
- int i;
uintptr_t expected_sum;
sum = 0;
/* Spawn the threads. */
- for (id = 0; id < THREAD_COUNT; id++)
+ for (unsigned int id = 0; id < THREAD_COUNT; id++)
ASSERT (thrd_create (&threads[id], dtorcheck1_thread, (void *) (uintptr_t) id)
== thrd_success);
/* Wait for the threads to terminate. */
- for (id = 0; id < THREAD_COUNT; id++)
+ for (unsigned int id = 0; id < THREAD_COUNT; id++)
ASSERT (thrd_join (threads[id], NULL) == thrd_success);
/* Clean up the keys. */
- for (id = 0; id < THREAD_COUNT; id++)
- for (i = 0; i < KEYS_COUNT; i++)
+ for (unsigned int id = 0; id < THREAD_COUNT; id++)
+ for (int i = 0; i < KEYS_COUNT; i++)
tss_delete (dtorcheck_keys[id][i]);
/* Check that the destructor was invoked for each key. */
{
unsigned int id = (unsigned int) (uintptr_t) arg;
tss_t *keys = dtorcheck_keys[id]; /* an array of KEYS_COUNT keys */
- int i;
- for (i = 0; i < KEYS_COUNT; i++)
+ for (int i = 0; i < KEYS_COUNT; i++)
ASSERT (tss_create (&keys[i], destructor_table[id]) == thrd_success);
- for (i = 0; i < KEYS_COUNT; i++)
+ for (int i = 0; i < KEYS_COUNT; i++)
ASSERT (tss_set (keys[i], (void *) (uintptr_t) (10 * i + id + 1))
== thrd_success);
test_tss_dtorcheck2 (void)
{
thrd_t threads[THREAD_COUNT];
- unsigned int id;
- int i;
uintptr_t expected_sum;
sum = 0;
/* Spawn the threads. */
- for (id = 0; id < THREAD_COUNT; id++)
+ for (unsigned int id = 0; id < THREAD_COUNT; id++)
ASSERT (thrd_create (&threads[id], dtorcheck2_thread, (void *) (uintptr_t) id)
== thrd_success);
/* Wait for the threads to terminate. */
- for (id = 0; id < THREAD_COUNT; id++)
+ for (unsigned int id = 0; id < THREAD_COUNT; id++)
ASSERT (thrd_join (threads[id], NULL) == thrd_success);
/* Clean up the keys. */
- for (id = 0; id < THREAD_COUNT; id++)
- for (i = 0; i < KEYS_COUNT; i++)
+ for (unsigned int id = 0; id < THREAD_COUNT; id++)
+ for (int i = 0; i < KEYS_COUNT; i++)
tss_delete (dtorcheck_keys[id][i]);
/* Check that the destructor was invoked for each key. */
{
unsigned int id = (unsigned int) (uintptr_t) arg;
tss_t *keys = racecheck_keys[id]; /* an array of KEYS_COUNT keys */
- int repeat;
- int i;
dbgprintf ("Worker %p started\n", thrd_current_pointer ());
- for (i = 0; i < KEYS_COUNT; i++)
+ for (int i = 0; i < KEYS_COUNT; i++)
{
ASSERT (tss_create (&keys[i], destructor_table[i]) == thrd_success);
ASSERT (tss_set (keys[i], (void *) (uintptr_t) (10 * id + i + 1))
== thrd_success);
}
- for (repeat = REPEAT_COUNT; repeat > 0; repeat--)
+ for (int repeat = REPEAT_COUNT; repeat > 0; repeat--)
{
- i = ((unsigned long) random () >> 3) % KEYS_COUNT;
+ int i = ((unsigned long) random () >> 3) % KEYS_COUNT;
dbgprintf ("Worker %p reallocating key %d\n", thrd_current_pointer (), i);
tss_delete (keys[i]);
ASSERT (tss_create (&keys[i], destructor_table[i]) == thrd_success);
test_tss_racecheck (void)
{
thrd_t threads[THREAD_COUNT];
- unsigned int id;
- int i;
uintptr_t expected_sum;
sum = 0;
/* Spawn the threads. */
- for (id = 0; id < THREAD_COUNT; id++)
+ for (unsigned int id = 0; id < THREAD_COUNT; id++)
ASSERT (thrd_create (&threads[id], racecheck_thread, (void *) (uintptr_t) id)
== thrd_success);
/* Wait for the threads to terminate. */
- for (id = 0; id < THREAD_COUNT; id++)
+ for (unsigned int id = 0; id < THREAD_COUNT; id++)
ASSERT (thrd_join (threads[id], NULL) == thrd_success);
/* Clean up the keys. */
- for (id = 0; id < THREAD_COUNT; id++)
- for (i = 0; i < KEYS_COUNT; i++)
+ for (unsigned int id = 0; id < THREAD_COUNT; id++)
+ for (int i = 0; i < KEYS_COUNT; i++)
tss_delete (racecheck_keys[id][i]);
/* Check that the destructor was invoked for each key. */
int
main (void)
{
- unsigned int i;
int fail = 0;
/* Find a UID that has both a user name and login group name,
but skip UID 0. */
- {
- uid_t uid;
- for (uid = 1200; 0 < uid; uid--)
- {
- struct group *gr;
- struct passwd *pw = getpwuid (uid);
- unsigned int j;
- size_t len;
- if (!pw || !pw->pw_name || !(gr = getgrgid (pw->pw_gid)) || !gr->gr_name)
- continue;
- j = ARRAY_CARDINALITY (T) - 1;
- len = strlen (pw->pw_name);
- if (sizeof T[j].in - 2 < len)
- continue;
+ for (uid_t uid = 1200; 0 < uid; uid--)
+ {
+ struct group *gr;
+ struct passwd *pw = getpwuid (uid);
+ unsigned int j;
+ size_t len;
+ if (!pw || !pw->pw_name || !(gr = getgrgid (pw->pw_gid)) || !gr->gr_name)
+ continue;
+ j = ARRAY_CARDINALITY (T) - 1;
+ len = strlen (pw->pw_name);
+ if (sizeof T[j].in - 2 < len)
+ continue;
- /* Store "username:" in T[j].in. */
- memcpy(T[j].in, pw->pw_name, len);
- strcpy(T[j].in + len, ":");
+ /* Store "username:" in T[j].in. */
+ memcpy(T[j].in, pw->pw_name, len);
+ strcpy(T[j].in + len, ":");
- T[j].uid = uid;
- T[j].gid = gr->gr_gid;
- T[j].user_name = xstrdup (pw->pw_name);
- T[j].group_name = xstrdup (gr->gr_name);
- T[j].result = NULL;
- break;
- }
- }
+ T[j].uid = uid;
+ T[j].gid = gr->gr_gid;
+ T[j].user_name = xstrdup (pw->pw_name);
+ T[j].group_name = xstrdup (gr->gr_name);
+ T[j].result = NULL;
+ break;
+ }
char *user_name = NULL;
char *group_name = NULL;
- for (i = 0; i < ARRAY_CARDINALITY (T); i++)
+ for (unsigned int i = 0; i < ARRAY_CARDINALITY (T); i++)
{
uid_t uid = (uid_t) -1;
gid_t gid = (gid_t) -1;
{
ASSERT (strlen (s) == len);
ASSERT (len == n1 + n2 + 3);
- size_t i;
- for (i = 0; i <= len; i++)
+ for (size_t i = 0; i <= len; i++)
s[i] = (i == 0 ? 'x' :
i <= n1 ? 'a' :
i == n1 + 1 ? 'y' :
{
ASSERT (strlen (s) == len);
ASSERT (len == n1 + 2);
- size_t i;
- for (i = 0; i <= len; i++)
+ for (size_t i = 0; i <= len; i++)
s[i] = (i == 0 ? 'x' :
i <= n1 ? 'a' :
i == n1 + 1 ? 'y' :
{
ASSERT (strlen (s) == len);
ASSERT (len == n1 + 2);
- size_t i;
- for (i = 0; i <= len; i++)
+ for (size_t i = 0; i <= len; i++)
s[i] = (i == 0 ? 'x' :
i <= n1 ? 'a' :
i == n1 + 1 ? 'y' :
{
ASSERT (strlen (s) == len);
ASSERT (len == n1 + 2);
- size_t i;
- for (i = 0; i <= len; i++)
+ for (size_t i = 0; i <= len; i++)
s[i] = (i == 0 ? 'x' :
i <= n1 ? 'a' :
i == n1 + 1 ? 'y' :
{
ASSERT (strlen (s) == len);
ASSERT (len == n1 + 2);
- size_t i;
- for (i = 0; i <= len; i++)
+ for (size_t i = 0; i <= len; i++)
s[i] = (i == 0 ? 'x' :
i <= n1 ? 'a' :
i == n1 + 1 ? 'y' :
test_function (char * (*my_asnprintf) (char *, size_t *, const char *, ...))
{
char buf[8];
- int size;
/* Test return value convention. */
- for (size = 0; size <= 8; size++)
+ for (int size = 0; size <= 8; size++)
{
size_t length = size;
char *result = my_asnprintf (NULL, &length, "%d", 12345);
free (result);
}
- for (size = 0; size <= 8; size++)
+ for (int size = 0; size <= 8; size++)
{
size_t length;
char *result;
{ 1.234321234321234e35, "123432123432123*********************.000000" },
{ 1.234321234321234e36, "123432123432123**********************.000000" }
};
- size_t k;
- for (k = 0; k < SIZEOF (data); k++)
+ for (size_t k = 0; k < SIZEOF (data); k++)
{
size_t length;
char *result =
{ 1.234321234321234e35L, "123432123432123*********************.000000" },
{ 1.234321234321234e36L, "123432123432123**********************.000000" }
};
- size_t k;
- for (k = 0; k < SIZEOF (data); k++)
+ for (size_t k = 0; k < SIZEOF (data); k++)
{
size_t length;
char *result =
{ 1.234321234321234e35, "1.234321e+35" },
{ 1.234321234321234e36, "1.234321e+36" }
};
- size_t k;
- for (k = 0; k < SIZEOF (data); k++)
+ for (size_t k = 0; k < SIZEOF (data); k++)
{
size_t length;
char *result =
{ 1.234321234321234e35L, "1.234321e+35" },
{ 1.234321234321234e36L, "1.234321e+36" }
};
- size_t k;
- for (k = 0; k < SIZEOF (data); k++)
+ for (size_t k = 0; k < SIZEOF (data); k++)
{
size_t length;
char *result =
{ 1.234321234321234e35, "1.23432e+35" },
{ 1.234321234321234e36, "1.23432e+36" }
};
- size_t k;
- for (k = 0; k < SIZEOF (data); k++)
+ for (size_t k = 0; k < SIZEOF (data); k++)
{
size_t length;
char *result =
{ 1.234321234321234e35L, "1.23432e+35" },
{ 1.234321234321234e36L, "1.23432e+36" }
};
- size_t k;
- for (k = 0; k < SIZEOF (data); k++)
+ for (size_t k = 0; k < SIZEOF (data); k++)
{
size_t length;
char *result =
size_t length;
char *result =
my_asnprintf (NULL, &length, "%.4000d %d", 1234567, 99);
- size_t i;
ASSERT (result != NULL);
- for (i = 0; i < 4000 - 7; i++)
+ for (size_t i = 0; i < 4000 - 7; i++)
ASSERT (result[i] == '0');
ASSERT (strcmp (result + 4000 - 7, "1234567 99") == 0);
ASSERT (length == strlen (result));
size_t length;
char *result =
my_asnprintf (NULL, &length, "%.*d %d", 4000, 1234567, 99);
- size_t i;
ASSERT (result != NULL);
- for (i = 0; i < 4000 - 7; i++)
+ for (size_t i = 0; i < 4000 - 7; i++)
ASSERT (result[i] == '0');
ASSERT (strcmp (result + 4000 - 7, "1234567 99") == 0);
ASSERT (length == strlen (result));
size_t length;
char *result =
my_asnprintf (NULL, &length, "%.4000d %d", -1234567, 99);
- size_t i;
ASSERT (result != NULL);
ASSERT (result[0] == '-');
- for (i = 0; i < 4000 - 7; i++)
+ for (size_t i = 0; i < 4000 - 7; i++)
ASSERT (result[1 + i] == '0');
ASSERT (strcmp (result + 1 + 4000 - 7, "1234567 99") == 0);
ASSERT (length == strlen (result));
size_t length;
char *result =
my_asnprintf (NULL, &length, "%.4000u %d", 1234567, 99);
- size_t i;
ASSERT (result != NULL);
- for (i = 0; i < 4000 - 7; i++)
+ for (size_t i = 0; i < 4000 - 7; i++)
ASSERT (result[i] == '0');
ASSERT (strcmp (result + 4000 - 7, "1234567 99") == 0);
ASSERT (length == strlen (result));
size_t length;
char *result =
my_asnprintf (NULL, &length, "%.4000o %d", 1234567, 99);
- size_t i;
ASSERT (result != NULL);
- for (i = 0; i < 4000 - 7; i++)
+ for (size_t i = 0; i < 4000 - 7; i++)
ASSERT (result[i] == '0');
ASSERT (strcmp (result + 4000 - 7, "4553207 99") == 0);
ASSERT (length == strlen (result));
size_t length;
char *result =
my_asnprintf (NULL, &length, "%.4000x %d", 1234567, 99);
- size_t i;
ASSERT (result != NULL);
- for (i = 0; i < 4000 - 6; i++)
+ for (size_t i = 0; i < 4000 - 6; i++)
ASSERT (result[i] == '0');
ASSERT (strcmp (result + 4000 - 6, "12d687 99") == 0);
ASSERT (length == strlen (result));
size_t length;
char *result =
my_asnprintf (NULL, &length, "%#.4000x %d", 1234567, 99);
- size_t i;
ASSERT (result != NULL);
ASSERT (result[0] == '0');
ASSERT (result[1] == 'x');
- for (i = 0; i < 4000 - 6; i++)
+ for (size_t i = 0; i < 4000 - 6; i++)
ASSERT (result[2 + i] == '0');
ASSERT (strcmp (result + 2 + 4000 - 6, "12d687 99") == 0);
ASSERT (length == strlen (result));
size_t length;
char *result =
my_asnprintf (NULL, &length, "%.4000f %d", 1.0, 99);
- size_t i;
ASSERT (result != NULL);
ASSERT (result[0] == '1');
ASSERT (result[1] == '.');
- for (i = 0; i < 4000; i++)
+ for (size_t i = 0; i < 4000; i++)
ASSERT (result[2 + i] == '0');
ASSERT (strcmp (result + 2 + 4000, " 99") == 0);
ASSERT (length == strlen (result));
size_t length;
char *result =
my_asnprintf (NULL, &length, "%.511f %d", 1.0, 99);
- size_t i;
ASSERT (result != NULL);
ASSERT (result[0] == '1');
ASSERT (result[1] == '.');
- for (i = 0; i < 511; i++)
+ for (size_t i = 0; i < 511; i++)
ASSERT (result[2 + i] == '0');
ASSERT (strcmp (result + 2 + 511, " 99") == 0);
ASSERT (length == strlen (result));
/* To verify that these tests succeed, it is necessary to run them under
a tool that checks against invalid memory accesses, such as ElectricFence
or "valgrind --tool=memcheck". */
- {
- size_t i;
-
- for (i = 1; i <= 8; i++)
- {
- char *block;
- size_t length;
- char *result;
-
- block = (char *) malloc (i);
- memcpy (block, "abcdefgh", i);
- result = my_asnprintf (NULL, &length, "%.*s", (int) i, block);
- ASSERT (result != NULL);
- ASSERT (memcmp (result, block, i) == 0);
- ASSERT (result[i] == '\0');
- ASSERT (length == strlen (result));
- free (result);
- free (block);
- }
- }
- {
- size_t i;
+ for (size_t i = 1; i <= 8; i++)
+ {
+ char *block;
+ size_t length;
+ char *result;
- for (i = 1; i <= 8; i++)
- {
- wchar_t *block;
- size_t j;
- size_t length;
- char *result;
+ block = (char *) malloc (i);
+ memcpy (block, "abcdefgh", i);
+ result = my_asnprintf (NULL, &length, "%.*s", (int) i, block);
+ ASSERT (result != NULL);
+ ASSERT (memcmp (result, block, i) == 0);
+ ASSERT (result[i] == '\0');
+ ASSERT (length == strlen (result));
+ free (result);
+ free (block);
+ }
+ for (size_t i = 1; i <= 8; i++)
+ {
+ wchar_t *block;
+ size_t length;
+ char *result;
- block = (wchar_t *) malloc (i * sizeof (wchar_t));
- for (j = 0; j < i; j++)
- block[j] = "abcdefgh"[j];
- result = my_asnprintf (NULL, &length, "%.*ls", (int) i, block);
- ASSERT (result != NULL);
- ASSERT (memcmp (result, "abcdefgh", i) == 0);
- ASSERT (result[i] == '\0');
- ASSERT (length == strlen (result));
- free (result);
- free (block);
- }
- }
+ block = (wchar_t *) malloc (i * sizeof (wchar_t));
+ for (size_t j = 0; j < i; j++)
+ block[j] = "abcdefgh"[j];
+ result = my_asnprintf (NULL, &length, "%.*ls", (int) i, block);
+ ASSERT (result != NULL);
+ ASSERT (memcmp (result, "abcdefgh", i) == 0);
+ ASSERT (result[i] == '\0');
+ ASSERT (length == strlen (result));
+ free (result);
+ free (block);
+ }
/* Test that converting an invalid wchar_t[] to char[] fails with EILSEQ. */
{
test_function (char * (*my_asnprintf) (char *, size_t *, const char *, ...))
{
char buf[8];
- int size;
- for (size = 0; size <= 8; size++)
+ for (int size = 0; size <= 8; size++)
{
size_t length = size;
char *result = my_asnprintf (NULL, &length, "%d", 12345);
free (result);
}
- for (size = 0; size <= 8; size++)
+ for (int size = 0; size <= 8; size++)
{
size_t length;
char *result;
}
/* Note: This test assumes IEEE 754 representation of 'double' floats. */
- for (size = 0; size <= 8; size++)
+ for (int size = 0; size <= 8; size++)
{
size_t length;
char *result;
{
ASSERT (wcslen (s) == len);
ASSERT (len == n1 + n2 + 3);
- size_t i;
- for (i = 0; i <= len; i++)
+ for (size_t i = 0; i <= len; i++)
s[i] = (i == 0 ? 'x' :
i <= n1 ? 'a' :
i == n1 + 1 ? 'y' :
{
ASSERT (wcslen (s) == len);
ASSERT (len == n1 + 2);
- size_t i;
- for (i = 0; i <= len; i++)
+ for (size_t i = 0; i <= len; i++)
s[i] = (i == 0 ? 'x' :
i <= n1 ? 'a' :
i == n1 + 1 ? 'y' :
{
ASSERT (wcslen (s) == len);
ASSERT (len == n1 + 2);
- size_t i;
- for (i = 0; i <= len; i++)
+ for (size_t i = 0; i <= len; i++)
s[i] = (i == 0 ? 'x' :
i <= n1 ? 'a' :
i == n1 + 1 ? 'y' :
{
ASSERT (wcslen (s) == len);
ASSERT (len == n1 + 2);
- size_t i;
- for (i = 0; i <= len; i++)
+ for (size_t i = 0; i <= len; i++)
s[i] = (i == 0 ? 'x' :
i <= n1 ? 'a' :
i == n1 + 1 ? 'y' :
{
ASSERT (wcslen (s) == len);
ASSERT (len == n1 + 2);
- size_t i;
- for (i = 0; i <= len; i++)
+ for (size_t i = 0; i <= len; i++)
s[i] = (i == 0 ? 'x' :
i <= n1 ? 'a' :
i == n1 + 1 ? 'y' :
test_function (wchar_t * (*my_asnwprintf) (wchar_t *, size_t *, const wchar_t *, ...))
{
wchar_t buf[8];
- int size;
/* Test return value convention. */
- for (size = 0; size <= 8; size++)
+ for (int size = 0; size <= 8; size++)
{
size_t length = size;
wchar_t *result = my_asnwprintf (NULL, &length, L"%d", 12345);
free (result);
}
- for (size = 0; size <= 8; size++)
+ for (int size = 0; size <= 8; size++)
{
size_t length;
wchar_t *result;
{ 1.234321234321234e35, L"123432123432123*********************.000000" },
{ 1.234321234321234e36, L"123432123432123**********************.000000" }
};
- size_t k;
- for (k = 0; k < SIZEOF (data); k++)
+ for (size_t k = 0; k < SIZEOF (data); k++)
{
size_t length;
wchar_t *result =
{ 1.234321234321234e35L, L"123432123432123*********************.000000" },
{ 1.234321234321234e36L, L"123432123432123**********************.000000" }
};
- size_t k;
- for (k = 0; k < SIZEOF (data); k++)
+ for (size_t k = 0; k < SIZEOF (data); k++)
{
size_t length;
wchar_t *result =
{ 1.234321234321234e35, L"1.234321e+35" },
{ 1.234321234321234e36, L"1.234321e+36" }
};
- size_t k;
- for (k = 0; k < SIZEOF (data); k++)
+ for (size_t k = 0; k < SIZEOF (data); k++)
{
size_t length;
wchar_t *result =
{ 1.234321234321234e35L, L"1.234321e+35" },
{ 1.234321234321234e36L, L"1.234321e+36" }
};
- size_t k;
- for (k = 0; k < SIZEOF (data); k++)
+ for (size_t k = 0; k < SIZEOF (data); k++)
{
size_t length;
wchar_t *result =
{ 1.234321234321234e35, L"1.23432e+35" },
{ 1.234321234321234e36, L"1.23432e+36" }
};
- size_t k;
- for (k = 0; k < SIZEOF (data); k++)
+ for (size_t k = 0; k < SIZEOF (data); k++)
{
size_t length;
wchar_t *result =
{ 1.234321234321234e35L, L"1.23432e+35" },
{ 1.234321234321234e36L, L"1.23432e+36" }
};
- size_t k;
- for (k = 0; k < SIZEOF (data); k++)
+ for (size_t k = 0; k < SIZEOF (data); k++)
{
size_t length;
wchar_t *result =
size_t length;
wchar_t *result =
my_asnwprintf (NULL, &length, L"%.4000d %d", 1234567, 99);
- size_t i;
ASSERT (result != NULL);
- for (i = 0; i < 4000 - 7; i++)
+ for (size_t i = 0; i < 4000 - 7; i++)
ASSERT (result[i] == '0');
ASSERT (wcscmp (result + 4000 - 7, L"1234567 99") == 0);
ASSERT (length == wcslen (result));
size_t length;
wchar_t *result =
my_asnwprintf (NULL, &length, L"%.*d %d", 4000, 1234567, 99);
- size_t i;
ASSERT (result != NULL);
- for (i = 0; i < 4000 - 7; i++)
+ for (size_t i = 0; i < 4000 - 7; i++)
ASSERT (result[i] == '0');
ASSERT (wcscmp (result + 4000 - 7, L"1234567 99") == 0);
ASSERT (length == wcslen (result));
size_t length;
wchar_t *result =
my_asnwprintf (NULL, &length, L"%.4000d %d", -1234567, 99);
- size_t i;
ASSERT (result != NULL);
ASSERT (result[0] == '-');
- for (i = 0; i < 4000 - 7; i++)
+ for (size_t i = 0; i < 4000 - 7; i++)
ASSERT (result[1 + i] == '0');
ASSERT (wcscmp (result + 1 + 4000 - 7, L"1234567 99") == 0);
ASSERT (length == wcslen (result));
size_t length;
wchar_t *result =
my_asnwprintf (NULL, &length, L"%.4000u %d", 1234567, 99);
- size_t i;
ASSERT (result != NULL);
- for (i = 0; i < 4000 - 7; i++)
+ for (size_t i = 0; i < 4000 - 7; i++)
ASSERT (result[i] == '0');
ASSERT (wcscmp (result + 4000 - 7, L"1234567 99") == 0);
ASSERT (length == wcslen (result));
size_t length;
wchar_t *result =
my_asnwprintf (NULL, &length, L"%.4000o %d", 1234567, 99);
- size_t i;
ASSERT (result != NULL);
- for (i = 0; i < 4000 - 7; i++)
+ for (size_t i = 0; i < 4000 - 7; i++)
ASSERT (result[i] == '0');
ASSERT (wcscmp (result + 4000 - 7, L"4553207 99") == 0);
ASSERT (length == wcslen (result));
size_t length;
wchar_t *result =
my_asnwprintf (NULL, &length, L"%.4000x %d", 1234567, 99);
- size_t i;
ASSERT (result != NULL);
- for (i = 0; i < 4000 - 6; i++)
+ for (size_t i = 0; i < 4000 - 6; i++)
ASSERT (result[i] == '0');
ASSERT (wcscmp (result + 4000 - 6, L"12d687 99") == 0);
ASSERT (length == wcslen (result));
size_t length;
wchar_t *result =
my_asnwprintf (NULL, &length, L"%#.4000x %d", 1234567, 99);
- size_t i;
ASSERT (result != NULL);
ASSERT (result[0] == '0');
ASSERT (result[1] == 'x');
- for (i = 0; i < 4000 - 6; i++)
+ for (size_t i = 0; i < 4000 - 6; i++)
ASSERT (result[2 + i] == '0');
ASSERT (wcscmp (result + 2 + 4000 - 6, L"12d687 99") == 0);
ASSERT (length == wcslen (result));
size_t length;
wchar_t *result =
my_asnwprintf (NULL, &length, L"%.4000f %d", 1.0, 99);
- size_t i;
ASSERT (result != NULL);
ASSERT (result[0] == '1');
ASSERT (result[1] == '.');
- for (i = 0; i < 4000; i++)
+ for (size_t i = 0; i < 4000; i++)
ASSERT (result[2 + i] == '0');
ASSERT (wcscmp (result + 2 + 4000, L" 99") == 0);
ASSERT (length == wcslen (result));
size_t length;
wchar_t *result =
my_asnwprintf (NULL, &length, L"%.511f %d", 1.0, 99);
- size_t i;
ASSERT (result != NULL);
ASSERT (result[0] == '1');
ASSERT (result[1] == '.');
- for (i = 0; i < 511; i++)
+ for (size_t i = 0; i < 511; i++)
ASSERT (result[2 + i] == '0');
ASSERT (wcscmp (result + 2 + 511, L" 99") == 0);
ASSERT (length == wcslen (result));
size_t length;
wchar_t *result;
wchar_t winput[5000];
- size_t i;
- for (i = 0; i < sizeof (input) - 1; i++)
- input[i] = 'a' + ((1000000 / (i + 1)) % 26);
- input[i] = '\0';
+ {
+ size_t i;
+ for (i = 0; i < sizeof (input) - 1; i++)
+ input[i] = 'a' + ((1000000 / (i + 1)) % 26);
+ input[i] = '\0';
+ }
result = my_asnwprintf (NULL, &length, L"%.4000s %d", input, 99);
ASSERT (result != NULL);
- for (i = 0; i < sizeof (input); i++)
+ for (size_t i = 0; i < sizeof (input); i++)
winput[i] = (wchar_t) input[i];
ASSERT (wmemcmp (result, winput, 4000) == 0);
ASSERT (wcscmp (result + 4000, L" 99") == 0);
invocations of mbrtowc(), and in the "C" and "POSIX" locales, "an
[EILSEQ] error cannot occur since all byte values are valid characters",
says POSIX:2018. */
- int c;
-
- for (c = 0; c < 0x100; c++)
+ for (int c = 0; c < 0x100; c++)
{
char s[2] = { c, '\0' };
size_t length;
/* To verify that these tests succeed, it is necessary to run them under
a tool that checks against invalid memory accesses, such as ElectricFence
or "valgrind --tool=memcheck". */
- {
- size_t i;
-
- for (i = 1; i <= 8; i++)
- {
- char *block;
- size_t length;
- wchar_t *result;
- wchar_t *wblock;
- size_t j;
-
- block = (char *) malloc (i);
- memcpy (block, "abcdefgh", i);
- result = my_asnwprintf (NULL, &length, L"%.*s", (int) i, block);
- ASSERT (result != NULL);
- wblock = (wchar_t *) malloc (i * sizeof (wchar_t));
- for (j = 0; j < i; j++)
- wblock[j] = (wchar_t) block[j];
- ASSERT (wmemcmp (result, wblock, i) == 0);
- ASSERT (result[i] == '\0');
- ASSERT (length == wcslen (result));
- free (result);
- free (block);
- }
- }
- {
- size_t i;
+ for (size_t i = 1; i <= 8; i++)
+ {
+ char *block;
+ size_t length;
+ wchar_t *result;
+ wchar_t *wblock;
- for (i = 1; i <= 8; i++)
- {
- wchar_t *block;
- size_t j;
- size_t length;
- wchar_t *result;
+ block = (char *) malloc (i);
+ memcpy (block, "abcdefgh", i);
+ result = my_asnwprintf (NULL, &length, L"%.*s", (int) i, block);
+ ASSERT (result != NULL);
+ wblock = (wchar_t *) malloc (i * sizeof (wchar_t));
+ for (size_t j = 0; j < i; j++)
+ wblock[j] = (wchar_t) block[j];
+ ASSERT (wmemcmp (result, wblock, i) == 0);
+ ASSERT (result[i] == '\0');
+ ASSERT (length == wcslen (result));
+ free (result);
+ free (block);
+ }
+ for (size_t i = 1; i <= 8; i++)
+ {
+ wchar_t *block;
+ size_t length;
+ wchar_t *result;
- block = (wchar_t *) malloc (i * sizeof (wchar_t));
- for (j = 0; j < i; j++)
- block[j] = "abcdefgh"[j];
- result = my_asnwprintf (NULL, &length, L"%.*ls", (int) i, block);
- ASSERT (result != NULL);
- ASSERT (wmemcmp (result, L"abcdefgh", i) == 0);
- ASSERT (result[i] == '\0');
- ASSERT (length == wcslen (result));
- free (result);
- free (block);
- }
- }
+ block = (wchar_t *) malloc (i * sizeof (wchar_t));
+ for (size_t j = 0; j < i; j++)
+ block[j] = "abcdefgh"[j];
+ result = my_asnwprintf (NULL, &length, L"%.*ls", (int) i, block);
+ ASSERT (result != NULL);
+ ASSERT (wmemcmp (result, L"abcdefgh", i) == 0);
+ ASSERT (result[i] == '\0');
+ ASSERT (length == wcslen (result));
+ free (result);
+ free (block);
+ }
/* Test that converting an invalid wchar_t[] to char[] fails with EILSEQ. */
{
{ /* The conversion of %c to wide character is done as if through btowc(),
and in the "C" and "POSIX" locales, "btowc() shall not return WEOF if
c has a value in the range 0 to 255 inclusive", says POSIX:2018. */
- int c;
-
- for (c = 0; c < 0x100; c++)
+ for (int c = 0; c < 0x100; c++)
{
size_t length;
wchar_t *result = my_asnwprintf (NULL, &length, L"%c", c);
test_function (wchar_t * (*my_asnwprintf) (wchar_t *, size_t *, const wchar_t *, ...))
{
wchar_t buf[8];
- int size;
- for (size = 0; size <= 8; size++)
+ for (int size = 0; size <= 8; size++)
{
size_t length = size;
wchar_t *result = my_asnwprintf (NULL, &length, L"%d", 12345);
free (result);
}
- for (size = 0; size <= 8; size++)
+ for (int size = 0; size <= 8; size++)
{
size_t length;
wchar_t *result;
}
/* Note: This test assumes IEEE 754 representation of 'double' floats. */
- for (size = 0; size <= 8; size++)
+ for (int size = 0; size <= 8; size++)
{
size_t length;
wchar_t *result;
static void
test_function (int (*my_asprintf) (char **, const char *, ...))
{
- int repeat;
-
/* Test return value convention. */
- for (repeat = 0; repeat <= 8; repeat++)
+ for (int repeat = 0; repeat <= 8; repeat++)
{
char *result;
int retval = asprintf (&result, "%d", 12345);
{ 1.234321234321234e35, "123432123432123*********************.000000" },
{ 1.234321234321234e36, "123432123432123**********************.000000" }
};
- size_t k;
- for (k = 0; k < SIZEOF (data); k++)
+ for (size_t k = 0; k < SIZEOF (data); k++)
{
char *result;
int retval =
{ 1.234321234321234e35L, "123432123432123*********************.000000" },
{ 1.234321234321234e36L, "123432123432123**********************.000000" }
};
- size_t k;
- for (k = 0; k < SIZEOF (data); k++)
+ for (size_t k = 0; k < SIZEOF (data); k++)
{
char *result;
int retval =
{ 1.234321234321234e35, "1.234321e+35" },
{ 1.234321234321234e36, "1.234321e+36" }
};
- size_t k;
- for (k = 0; k < SIZEOF (data); k++)
+ for (size_t k = 0; k < SIZEOF (data); k++)
{
char *result;
int retval =
{ 1.234321234321234e35L, "1.234321e+35" },
{ 1.234321234321234e36L, "1.234321e+36" }
};
- size_t k;
- for (k = 0; k < SIZEOF (data); k++)
+ for (size_t k = 0; k < SIZEOF (data); k++)
{
char *result;
int retval =
{ 1.234321234321234e35, "1.23432e+35" },
{ 1.234321234321234e36, "1.23432e+36" }
};
- size_t k;
- for (k = 0; k < SIZEOF (data); k++)
+ for (size_t k = 0; k < SIZEOF (data); k++)
{
char *result;
int retval =
{ 1.234321234321234e35L, "1.23432e+35" },
{ 1.234321234321234e36L, "1.23432e+36" }
};
- size_t k;
- for (k = 0; k < SIZEOF (data); k++)
+ for (size_t k = 0; k < SIZEOF (data); k++)
{
char *result;
int retval =
char *result;
int retval =
my_asprintf (&result, "%.4000d %d", 1234567, 99);
- size_t i;
ASSERT (result != NULL);
- for (i = 0; i < 4000 - 7; i++)
+ for (size_t i = 0; i < 4000 - 7; i++)
ASSERT (result[i] == '0');
ASSERT (strcmp (result + 4000 - 7, "1234567 99") == 0);
ASSERT (retval == strlen (result));
char *result;
int retval =
my_asprintf (&result, "%.*d %d", 4000, 1234567, 99);
- size_t i;
ASSERT (result != NULL);
- for (i = 0; i < 4000 - 7; i++)
+ for (size_t i = 0; i < 4000 - 7; i++)
ASSERT (result[i] == '0');
ASSERT (strcmp (result + 4000 - 7, "1234567 99") == 0);
ASSERT (retval == strlen (result));
char *result;
int retval =
my_asprintf (&result, "%.4000d %d", -1234567, 99);
- size_t i;
ASSERT (result != NULL);
ASSERT (result[0] == '-');
- for (i = 0; i < 4000 - 7; i++)
+ for (size_t i = 0; i < 4000 - 7; i++)
ASSERT (result[1 + i] == '0');
ASSERT (strcmp (result + 1 + 4000 - 7, "1234567 99") == 0);
ASSERT (retval == strlen (result));
char *result;
int retval =
my_asprintf (&result, "%.4000u %d", 1234567, 99);
- size_t i;
ASSERT (result != NULL);
- for (i = 0; i < 4000 - 7; i++)
+ for (size_t i = 0; i < 4000 - 7; i++)
ASSERT (result[i] == '0');
ASSERT (strcmp (result + 4000 - 7, "1234567 99") == 0);
ASSERT (retval == strlen (result));
char *result;
int retval =
my_asprintf (&result, "%.4000o %d", 1234567, 99);
- size_t i;
ASSERT (result != NULL);
- for (i = 0; i < 4000 - 7; i++)
+ for (size_t i = 0; i < 4000 - 7; i++)
ASSERT (result[i] == '0');
ASSERT (strcmp (result + 4000 - 7, "4553207 99") == 0);
ASSERT (retval == strlen (result));
char *result;
int retval =
my_asprintf (&result, "%.4000x %d", 1234567, 99);
- size_t i;
ASSERT (result != NULL);
- for (i = 0; i < 4000 - 6; i++)
+ for (size_t i = 0; i < 4000 - 6; i++)
ASSERT (result[i] == '0');
ASSERT (strcmp (result + 4000 - 6, "12d687 99") == 0);
ASSERT (retval == strlen (result));
char *result;
int retval =
my_asprintf (&result, "%#.4000x %d", 1234567, 99);
- size_t i;
ASSERT (result != NULL);
ASSERT (result[0] == '0');
ASSERT (result[1] == 'x');
- for (i = 0; i < 4000 - 6; i++)
+ for (size_t i = 0; i < 4000 - 6; i++)
ASSERT (result[2 + i] == '0');
ASSERT (strcmp (result + 2 + 4000 - 6, "12d687 99") == 0);
ASSERT (retval == strlen (result));
char *result;
int retval =
my_asprintf (&result, "%.4000f %d", 1.0, 99);
- size_t i;
ASSERT (result != NULL);
ASSERT (result[0] == '1');
ASSERT (result[1] == '.');
- for (i = 0; i < 4000; i++)
+ for (size_t i = 0; i < 4000; i++)
ASSERT (result[2 + i] == '0');
ASSERT (strcmp (result + 2 + 4000, " 99") == 0);
ASSERT (retval == strlen (result));
char *result;
int retval =
my_asprintf (&result, "%.511f %d", 1.0, 99);
- size_t i;
ASSERT (result != NULL);
ASSERT (result[0] == '1');
ASSERT (result[1] == '.');
- for (i = 0; i < 511; i++)
+ for (size_t i = 0; i < 511; i++)
ASSERT (result[2 + i] == '0');
ASSERT (strcmp (result + 2 + 511, " 99") == 0);
ASSERT (retval == strlen (result));
/* To verify that these tests succeed, it is necessary to run them under
a tool that checks against invalid memory accesses, such as ElectricFence
or "valgrind --tool=memcheck". */
- {
- size_t i;
-
- for (i = 1; i <= 8; i++)
- {
- char *block;
- char *result;
- int retval;
-
- block = (char *) malloc (i);
- memcpy (block, "abcdefgh", i);
- retval = my_asprintf (&result, "%.*s", (int) i, block);
- ASSERT (result != NULL);
- ASSERT (memcmp (result, block, i) == 0);
- ASSERT (result[i] == '\0');
- ASSERT (retval == strlen (result));
- free (result);
- free (block);
- }
- }
- {
- size_t i;
+ for (size_t i = 1; i <= 8; i++)
+ {
+ char *block;
+ char *result;
+ int retval;
- for (i = 1; i <= 8; i++)
- {
- wchar_t *block;
- size_t j;
- char *result;
- int retval;
+ block = (char *) malloc (i);
+ memcpy (block, "abcdefgh", i);
+ retval = my_asprintf (&result, "%.*s", (int) i, block);
+ ASSERT (result != NULL);
+ ASSERT (memcmp (result, block, i) == 0);
+ ASSERT (result[i] == '\0');
+ ASSERT (retval == strlen (result));
+ free (result);
+ free (block);
+ }
+ for (size_t i = 1; i <= 8; i++)
+ {
+ wchar_t *block;
+ char *result;
+ int retval;
- block = (wchar_t *) malloc (i * sizeof (wchar_t));
- for (j = 0; j < i; j++)
- block[j] = "abcdefgh"[j];
- retval = my_asprintf (&result, "%.*ls", (int) i, block);
- ASSERT (result != NULL);
- ASSERT (memcmp (result, "abcdefgh", i) == 0);
- ASSERT (result[i] == '\0');
- ASSERT (retval == strlen (result));
- free (result);
- free (block);
- }
- }
+ block = (wchar_t *) malloc (i * sizeof (wchar_t));
+ for (size_t j = 0; j < i; j++)
+ block[j] = "abcdefgh"[j];
+ retval = my_asprintf (&result, "%.*ls", (int) i, block);
+ ASSERT (result != NULL);
+ ASSERT (memcmp (result, "abcdefgh", i) == 0);
+ ASSERT (result[i] == '\0');
+ ASSERT (retval == strlen (result));
+ free (result);
+ free (block);
+ }
/* Test the support of the %c format directive. */
static void
test_vasprintf ()
{
- int repeat;
-
- for (repeat = 0; repeat <= 8; repeat++)
+ for (int repeat = 0; repeat <= 8; repeat++)
{
char *result;
int retval = my_asprintf (&result, "%d", 12345);
free (result);
}
- for (repeat = 0; repeat <= 8; repeat++)
+ for (int repeat = 0; repeat <= 8; repeat++)
{
char *result;
int retval = my_asprintf (&result, "%08lx", 12345UL);
static void
test_asprintf ()
{
- int repeat;
-
- for (repeat = 0; repeat <= 8; repeat++)
+ for (int repeat = 0; repeat <= 8; repeat++)
{
char *result;
int retval = asprintf (&result, "%d", 12345);
free (result);
}
- for (repeat = 0; repeat <= 8; repeat++)
+ for (int repeat = 0; repeat <= 8; repeat++)
{
char *result;
int retval = asprintf (&result, "%08lx", 12345UL);
ptrdiff_t retval =
my_aszprintf (&result, "%.4000d %d", 1234567, 99);
ASSERT (result != NULL);
- size_t i;
- for (i = 0; i < 4000 - 7; i++)
+ for (size_t i = 0; i < 4000 - 7; i++)
ASSERT (result[i] == '0');
ASSERT (strcmp (result + 4000 - 7, "1234567 99") == 0);
ASSERT (retval == strlen (result));
main (int argc, char *argv[])
{
char buf[8];
- int size;
int retval;
retval = my_snprintf (NULL, 0, "%d", 12345);
ASSERT (retval == 5);
- for (size = 0; size <= 8; size++)
+ for (int size = 0; size <= 8; size++)
{
memcpy (buf, "DEADBEEF", 8);
retval = my_snprintf (buf, size, "%d", 12345);
}
/* Test single bytes. */
- {
- int c;
-
- for (c = 0; c < 0x100; c++)
- switch (c)
- {
- case '\t': case '\v': case '\f':
- case ' ': case '!': case '"': case '#': case '%':
- case '&': case '\'': case '(': case ')': case '*':
- case '+': case ',': case '-': case '.': case '/':
- case '0': case '1': case '2': case '3': case '4':
- case '5': case '6': case '7': case '8': case '9':
- case ':': case ';': case '<': case '=': case '>':
- case '?':
- case 'A': case 'B': case 'C': case 'D': case 'E':
- case 'F': case 'G': case 'H': case 'I': case 'J':
- case 'K': case 'L': case 'M': case 'N': case 'O':
- case 'P': case 'Q': case 'R': case 'S': case 'T':
- case 'U': case 'V': case 'W': case 'X': case 'Y':
- case 'Z':
- case '[': case '\\': case ']': case '^': case '_':
- case 'a': case 'b': case 'c': case 'd': case 'e':
- case 'f': case 'g': case 'h': case 'i': case 'j':
- case 'k': case 'l': case 'm': case 'n': case 'o':
- case 'p': case 'q': case 'r': case 's': case 't':
- case 'u': case 'v': case 'w': case 'x': case 'y':
- case 'z': case '{': case '|': case '}': case '~':
- /* c is in the ISO C "basic character set". */
- ret = wcrtomb (buf, btowc (c), NULL);
- ASSERT (ret == 1);
- ASSERT (buf[0] == (char) c);
- break;
- }
- }
+ for (int c = 0; c < 0x100; c++)
+ switch (c)
+ {
+ case '\t': case '\v': case '\f':
+ case ' ': case '!': case '"': case '#': case '%':
+ case '&': case '\'': case '(': case ')': case '*':
+ case '+': case ',': case '-': case '.': case '/':
+ case '0': case '1': case '2': case '3': case '4':
+ case '5': case '6': case '7': case '8': case '9':
+ case ':': case ';': case '<': case '=': case '>':
+ case '?':
+ case 'A': case 'B': case 'C': case 'D': case 'E':
+ case 'F': case 'G': case 'H': case 'I': case 'J':
+ case 'K': case 'L': case 'M': case 'N': case 'O':
+ case 'P': case 'Q': case 'R': case 'S': case 'T':
+ case 'U': case 'V': case 'W': case 'X': case 'Y':
+ case 'Z':
+ case '[': case '\\': case ']': case '^': case '_':
+ case 'a': case 'b': case 'c': case 'd': case 'e':
+ case 'f': case 'g': case 'h': case 'i': case 'j':
+ case 'k': case 'l': case 'm': case 'n': case 'o':
+ case 'p': case 'q': case 'r': case 's': case 't':
+ case 'u': case 'v': case 'w': case 'x': case 'y':
+ case 'z': case '{': case '|': case '}': case '~':
+ /* c is in the ISO C "basic character set". */
+ ret = wcrtomb (buf, btowc (c), NULL);
+ ASSERT (ret == 1);
+ ASSERT (buf[0] == (char) c);
+ break;
+ }
/* Test special calling convention, passing a NULL pointer. */
{
{
int codepage = atoi (argv[argc - 1]);
int result;
- int i;
result = 77;
- for (i = 1; i < argc - 1; i++)
+ for (int i = 1; i < argc - 1; i++)
{
int ret = test_one_locale (argv[i], codepage);
}
/* Test single bytes. */
- {
- int c;
-
- for (c = 0; c < 0x100; c++)
- switch (c)
- {
- case '\t': case '\v': case '\f':
- case ' ': case '!': case '"': case '#': case '%':
- case '&': case '\'': case '(': case ')': case '*':
- case '+': case ',': case '-': case '.': case '/':
- case '0': case '1': case '2': case '3': case '4':
- case '5': case '6': case '7': case '8': case '9':
- case ':': case ';': case '<': case '=': case '>':
- case '?':
- case 'A': case 'B': case 'C': case 'D': case 'E':
- case 'F': case 'G': case 'H': case 'I': case 'J':
- case 'K': case 'L': case 'M': case 'N': case 'O':
- case 'P': case 'Q': case 'R': case 'S': case 'T':
- case 'U': case 'V': case 'W': case 'X': case 'Y':
- case 'Z':
- case '[': case '\\': case ']': case '^': case '_':
- case 'a': case 'b': case 'c': case 'd': case 'e':
- case 'f': case 'g': case 'h': case 'i': case 'j':
- case 'k': case 'l': case 'm': case 'n': case 'o':
- case 'p': case 'q': case 'r': case 's': case 't':
- case 'u': case 'v': case 'w': case 'x': case 'y':
- case 'z': case '{': case '|': case '}': case '~':
- /* c is in the ISO C "basic character set". */
- ret = wcrtomb (buf, btowc (c), NULL);
- ASSERT (ret == 1);
- ASSERT (buf[0] == (char) c);
- break;
- }
- }
+ for (int c = 0; c < 0x100; c++)
+ switch (c)
+ {
+ case '\t': case '\v': case '\f':
+ case ' ': case '!': case '"': case '#': case '%':
+ case '&': case '\'': case '(': case ')': case '*':
+ case '+': case ',': case '-': case '.': case '/':
+ case '0': case '1': case '2': case '3': case '4':
+ case '5': case '6': case '7': case '8': case '9':
+ case ':': case ';': case '<': case '=': case '>':
+ case '?':
+ case 'A': case 'B': case 'C': case 'D': case 'E':
+ case 'F': case 'G': case 'H': case 'I': case 'J':
+ case 'K': case 'L': case 'M': case 'N': case 'O':
+ case 'P': case 'Q': case 'R': case 'S': case 'T':
+ case 'U': case 'V': case 'W': case 'X': case 'Y':
+ case 'Z':
+ case '[': case '\\': case ']': case '^': case '_':
+ case 'a': case 'b': case 'c': case 'd': case 'e':
+ case 'f': case 'g': case 'h': case 'i': case 'j':
+ case 'k': case 'l': case 'm': case 'n': case 'o':
+ case 'p': case 'q': case 'r': case 's': case 't':
+ case 'u': case 'v': case 'w': case 'x': case 'y':
+ case 'z': case '{': case '|': case '}': case '~':
+ /* c is in the ISO C "basic character set". */
+ ret = wcrtomb (buf, btowc (c), NULL);
+ ASSERT (ret == 1);
+ ASSERT (buf[0] == (char) c);
+ break;
+ }
/* Test special calling convention, passing a NULL pointer. */
{
if (argc > 1)
{
wchar_t input[10];
- size_t n;
const wchar_t *src;
#define BUFSIZE 20
char buf[BUFSIZE];
size_t ret;
- {
- size_t i;
- for (i = 0; i < BUFSIZE; i++)
- buf[i] = '_';
- }
+ for (size_t i = 0; i < BUFSIZE; i++)
+ buf[i] = '_';
switch (argv[1][0])
{
ret = mbstowcs (input, original, 10);
ASSERT (ret == 5);
- for (n = 0; n < 10; n++)
+ for (size_t n = 0; n < 10; n++)
{
src = input;
ret = wcsnrtombs (NULL, &src, 6, n, NULL);
ret = mbstowcs (input, original, 10);
ASSERT (ret == 5);
- for (n = 0; n < 10; n++)
+ for (size_t n = 0; n < 10; n++)
{
src = input;
ret = wcsnrtombs (NULL, &src, 6, n, NULL);
ret = mbstowcs (input, original, 10);
ASSERT (ret == 5);
- for (n = 0; n < 10; n++)
+ for (size_t n = 0; n < 10; n++)
{
src = input;
ret = wcsnrtombs (NULL, &src, 6, n, NULL);
ret = mbstowcs (input, original, 10);
ASSERT (ret == 5);
- for (n = 0; n < 10; n++)
+ for (size_t n = 0; n < 10; n++)
{
src = input;
ret = wcsnrtombs (NULL, &src, 6, n, NULL);
if (argc > 1)
{
wchar_t input[10];
- size_t n;
const wchar_t *src;
#define BUFSIZE 20
char buf[BUFSIZE];
size_t ret;
- {
- size_t i;
- for (i = 0; i < BUFSIZE; i++)
- buf[i] = '_';
- }
+ for (size_t i = 0; i < BUFSIZE; i++)
+ buf[i] = '_';
switch (argv[1][0])
{
ret = mbstowcs (input, original, 10);
ASSERT (ret == 5);
- for (n = 0; n < 10; n++)
+ for (size_t n = 0; n < 10; n++)
{
src = input;
ret = wcsrtombs (NULL, &src, n, NULL);
ret = mbstowcs (input, original, 10);
ASSERT (ret == 5);
- for (n = 0; n < 10; n++)
+ for (size_t n = 0; n < 10; n++)
{
src = input;
ret = wcsrtombs (NULL, &src, n, NULL);
ret = mbstowcs (input, original, 10);
ASSERT (ret == 5);
- for (n = 0; n < 10; n++)
+ for (size_t n = 0; n < 10; n++)
{
src = input;
ret = wcsrtombs (NULL, &src, n, NULL);
ret = mbstowcs (input, original, 10);
ASSERT (ret == 5);
- for (n = 0; n < 10; n++)
+ for (size_t n = 0; n < 10; n++)
{
src = input;
ret = wcsrtombs (NULL, &src, n, NULL);
int
main ()
{
- wchar_t wc;
-
#if !GNULIB_WCHAR_SINGLE_LOCALE
# ifdef C_CTYPE_ASCII
/* Test width of ASCII characters. */
- for (wc = 0x20; wc < 0x7F; wc++)
+ for (wchar_t wc = 0x20; wc < 0x7F; wc++)
ASSERT (wcwidth (wc) == 1);
# endif
#endif
&& strcmp (locale_charset (), "UTF-8") == 0)
{
/* Test width of ASCII characters. */
- for (wc = 0x20; wc < 0x7F; wc++)
+ for (wchar_t wc = 0x20; wc < 0x7F; wc++)
ASSERT (wcwidth (wc) == 1);
/* Test width of some non-spacing characters. */
if (argc > 1)
{
/* Test cases given on the command line. */
- int i;
-
error_print_progname = print_no_progname;
- for (i = 1; i < argc; i++)
+ for (int i = 1; i < argc; i++)
{
char *p;
__strtol_t val;
static void
test_xvasprintf (void)
{
- int repeat;
char *result;
- for (repeat = 0; repeat <= 8; repeat++)
+ for (int repeat = 0; repeat <= 8; repeat++)
{
result = my_xasprintf ("%d", 12345);
ASSERT (result != NULL);
static void
test_xasprintf (void)
{
- int repeat;
char *result;
- for (repeat = 0; repeat <= 8; repeat++)
+ for (int repeat = 0; repeat <= 8; repeat++)
{
result = xasprintf ("%d", 12345);
ASSERT (result != NULL);
main ()
{
unsigned int c;
- size_t i;
c = 0;
- for (i = 0; i < SIZEOF (mapping); i++)
+ for (size_t i = 0; i < SIZEOF (mapping); i++)
{
for (; c < mapping[i].ch; c++)
ASSERT (MAP (c) == c);
main ()
{
unsigned int c;
- size_t i;
c = 0;
- for (i = 0; i < SIZEOF (set); i++)
+ for (size_t i = 0; i < SIZEOF (set); i++)
{
for (; c < set[i].start; c++)
ASSERT (!PREDICATE (c));
#if HAVE_ICONV
static enum iconv_ilseq_handler handlers[] =
{ iconveh_error, iconveh_question_mark, iconveh_escape_sequence };
- size_t h;
- size_t o;
- size_t i;
/* Assume that iconv() supports at least the encodings ASCII, ISO-8859-1,
ISO-8859-2, and UTF-8. */
/* Test conversion from ISO-8859-1 to UTF-16 with no errors. */
- for (h = 0; h < SIZEOF (handlers); h++)
+ for (size_t h = 0; h < SIZEOF (handlers); h++)
{
enum iconv_ilseq_handler handler = handlers[h];
static const char input[] = "\304rger mit b\366sen B\374bchen ohne Augenma\337";
'e', 'n', ' ', 'B', 0xFC, 'b', 'c', 'h', 'e', 'n', ' ', 'o', 'h',
'n', 'e', ' ', 'A', 'u', 'g', 'e', 'n', 'm', 'a', 0xDF
};
- for (o = 0; o < 2; o++)
+ for (size_t o = 0; o < 2; o++)
{
size_t *offsets = (o ? new_offsets (strlen (input)) : NULL);
size_t length;
ASSERT (u16_cmp (result, expected, SIZEOF (expected)) == 0);
if (o)
{
- for (i = 0; i < 37; i++)
+ for (size_t i = 0; i < 37; i++)
ASSERT (offsets[i] == i);
ASSERT (offsets[37] == MAGIC);
free (offsets);
}
/* Test conversion from ISO-8859-2 to UTF-16 with no errors. */
- for (h = 0; h < SIZEOF (handlers); h++)
+ for (size_t h = 0; h < SIZEOF (handlers); h++)
{
enum iconv_ilseq_handler handler = handlers[h];
static const char input[] = "Rafa\263 Maszkowski"; /* Rafał Maszkowski */
'R', 'a', 'f', 'a', 0x0142, ' ', 'M', 'a', 's', 'z', 'k', 'o', 'w',
's', 'k', 'i'
};
- for (o = 0; o < 2; o++)
+ for (size_t o = 0; o < 2; o++)
{
size_t *offsets = (o ? new_offsets (strlen (input)) : NULL);
size_t length;
ASSERT (u16_cmp (result, expected, SIZEOF (expected)) == 0);
if (o)
{
- for (i = 0; i < 16; i++)
+ for (size_t i = 0; i < 16; i++)
ASSERT (offsets[i] == i);
ASSERT (offsets[16] == MAGIC);
free (offsets);
if (iconv_supports_encoding ("ISO-2022-JP-2"))
{
/* Test conversions from autodetect_jp to UTF-16. */
- for (h = 0; h < SIZEOF (handlers); h++)
+ for (size_t h = 0; h < SIZEOF (handlers); h++)
{
enum iconv_ilseq_handler handler = handlers[h];
static const char input[] = "\244\263\244\363\244\313\244\301\244\317"; /* こんにちは in EUC-JP */
{
0x3053, 0x3093, 0x306B, 0x3061, 0x306F
};
- for (o = 0; o < 2; o++)
+ for (size_t o = 0; o < 2; o++)
{
size_t *offsets = (o ? new_offsets (strlen (input)) : NULL);
size_t length;
ASSERT (u16_cmp (result, expected, SIZEOF (expected)) == 0);
if (o)
{
- for (i = 0; i < 10; i++)
+ for (size_t i = 0; i < 10; i++)
ASSERT (offsets[i] == ((i % 2) == 0 ? i / 2 : (size_t)(-1)));
ASSERT (offsets[10] == MAGIC);
free (offsets);
free (result);
}
}
- for (h = 0; h < SIZEOF (handlers); h++)
+ for (size_t h = 0; h < SIZEOF (handlers); h++)
{
enum iconv_ilseq_handler handler = handlers[h];
static const char input[] = "\202\261\202\361\202\311\202\277\202\315"; /* こんにちは in Shift_JIS */
{
0x3053, 0x3093, 0x306B, 0x3061, 0x306F
};
- for (o = 0; o < 2; o++)
+ for (size_t o = 0; o < 2; o++)
{
size_t *offsets = (o ? new_offsets (strlen (input)) : NULL);
size_t length;
ASSERT (u16_cmp (result, expected, SIZEOF (expected)) == 0);
if (o)
{
- for (i = 0; i < 10; i++)
+ for (size_t i = 0; i < 10; i++)
ASSERT (offsets[i] == ((i % 2) == 0 ? i / 2 : (size_t)(-1)));
ASSERT (offsets[10] == MAGIC);
free (offsets);
free (result);
}
}
- for (h = 0; h < SIZEOF (handlers); h++)
+ for (size_t h = 0; h < SIZEOF (handlers); h++)
{
enum iconv_ilseq_handler handler = handlers[h];
static const char input[] = "\033$B$3$s$K$A$O\033(B"; /* こんにちは in ISO-2022-JP-2 */
{
0x3053, 0x3093, 0x306B, 0x3061, 0x306F
};
- for (o = 0; o < 2; o++)
+ for (size_t o = 0; o < 2; o++)
{
size_t *offsets = (o ? new_offsets (strlen (input)) : NULL);
size_t length;
ASSERT (u16_cmp (result, expected, SIZEOF (expected)) == 0);
if (o)
{
- for (i = 0; i < 16; i++)
+ for (size_t i = 0; i < 16; i++)
ASSERT (offsets[i] == (i == 0 ? 0 :
i == 5 ? 1 :
i == 7 ? 2 :
#if HAVE_ICONV
static enum iconv_ilseq_handler handlers[] =
{ iconveh_error, iconveh_question_mark, iconveh_escape_sequence };
- size_t h;
- size_t o;
- size_t i;
/* Assume that iconv() supports at least the encodings ASCII, ISO-8859-1,
ISO-8859-2, and UTF-8. */
/* Test conversion from UTF-16 to ISO-8859-1 with no errors. */
- for (h = 0; h < SIZEOF (handlers); h++)
+ for (size_t h = 0; h < SIZEOF (handlers); h++)
{
enum iconv_ilseq_handler handler = handlers[h];
static const uint16_t input[] = /* Ärger mit bösen Bübchen ohne Augenmaß */
'n', 'e', ' ', 'A', 'u', 'g', 'e', 'n', 'm', 'a', 0xDF
};
static const char expected[] = "\304rger mit b\366sen B\374bchen ohne Augenma\337";
- for (o = 0; o < 2; o++)
+ for (size_t o = 0; o < 2; o++)
{
size_t *offsets = (o ? new_offsets (SIZEOF (input)) : NULL);
size_t length;
ASSERT (memcmp (result, expected, length) == 0);
if (o)
{
- for (i = 0; i < 37; i++)
+ for (size_t i = 0; i < 37; i++)
ASSERT (offsets[i] == i);
ASSERT (offsets[37] == MAGIC);
free (offsets);
}
/* Test conversion from UTF-16 to ISO-8859-1 with EILSEQ. */
- for (h = 0; h < SIZEOF (handlers); h++)
+ for (size_t h = 0; h < SIZEOF (handlers); h++)
{
enum iconv_ilseq_handler handler = handlers[h];
static const uint16_t input[] = /* Rafał Maszkowski */
'R', 'a', 'f', 'a', 0x0142, ' ', 'M', 'a', 's', 'z', 'k', 'o', 'w',
's', 'k', 'i'
};
- for (o = 0; o < 2; o++)
+ for (size_t o = 0; o < 2; o++)
{
size_t *offsets = (o ? new_offsets (SIZEOF (input)) : NULL);
size_t length = 0xdead;
|| memcmp (result, expected_translit, length) == 0);
if (o)
{
- for (i = 0; i < 16; i++)
+ for (size_t i = 0; i < 16; i++)
ASSERT (offsets[i] == i);
ASSERT (offsets[16] == MAGIC);
free (offsets);
ASSERT (memcmp (result, expected, length) == 0);
if (o)
{
- for (i = 0; i < 16; i++)
+ for (size_t i = 0; i < 16; i++)
ASSERT (offsets[i] == (i < 5 ? i : i + 5));
ASSERT (offsets[16] == MAGIC);
free (offsets);
}
/* Test conversion from UTF-16 to ISO-8859-1 with EINVAL. */
- for (h = 0; h < SIZEOF (handlers); h++)
+ for (size_t h = 0; h < SIZEOF (handlers); h++)
{
enum iconv_ilseq_handler handler = handlers[h];
static const uint16_t input[] = { 0xD845 };
- for (o = 0; o < 2; o++)
+ for (size_t o = 0; o < 2; o++)
{
size_t *offsets = (o ? new_offsets (SIZEOF (input)) : NULL);
size_t length;
#if HAVE_ICONV
static enum iconv_ilseq_handler handlers[] =
{ iconveh_error, iconveh_question_mark, iconveh_escape_sequence };
- size_t h;
/* Assume that iconv() supports at least the encodings ASCII, ISO-8859-1,
ISO-8859-2, and UTF-8. */
/* Test conversion from ISO-8859-1 to UTF-16 with no errors. */
- for (h = 0; h < SIZEOF (handlers); h++)
+ for (size_t h = 0; h < SIZEOF (handlers); h++)
{
enum iconv_ilseq_handler handler = handlers[h];
static const char input[] = "\304rger mit b\366sen B\374bchen ohne Augenma\337";
}
/* Test conversion from ISO-8859-2 to UTF-16 with no errors. */
- for (h = 0; h < SIZEOF (handlers); h++)
+ for (size_t h = 0; h < SIZEOF (handlers); h++)
{
enum iconv_ilseq_handler handler = handlers[h];
static const char input[] = "Rafa\263 Maszkowski"; /* Rafał Maszkowski */
if (iconv_supports_encoding ("ISO-2022-JP-2"))
{
/* Test conversions from autodetect_jp to UTF-16. */
- for (h = 0; h < SIZEOF (handlers); h++)
+ for (size_t h = 0; h < SIZEOF (handlers); h++)
{
enum iconv_ilseq_handler handler = handlers[h];
static const char input[] = "\244\263\244\363\244\313\244\301\244\317"; /* こんにちは in EUC-JP */
ASSERT (u16_strcmp (result, expected) == 0);
free (result);
}
- for (h = 0; h < SIZEOF (handlers); h++)
+ for (size_t h = 0; h < SIZEOF (handlers); h++)
{
enum iconv_ilseq_handler handler = handlers[h];
static const char input[] = "\202\261\202\361\202\311\202\277\202\315"; /* こんにちは in Shift_JIS */
ASSERT (u16_strcmp (result, expected) == 0);
free (result);
}
- for (h = 0; h < SIZEOF (handlers); h++)
+ for (size_t h = 0; h < SIZEOF (handlers); h++)
{
enum iconv_ilseq_handler handler = handlers[h];
static const char input[] = "\033$B$3$s$K$A$O\033(B"; /* こんにちは in ISO-2022-JP-2 */
#if HAVE_ICONV
static enum iconv_ilseq_handler handlers[] =
{ iconveh_error, iconveh_question_mark, iconveh_escape_sequence };
- size_t h;
/* Assume that iconv() supports at least the encodings ASCII, ISO-8859-1,
ISO-8859-2, and UTF-8. */
/* Test conversion from UTF-16 to ISO-8859-1 with no errors. */
- for (h = 0; h < SIZEOF (handlers); h++)
+ for (size_t h = 0; h < SIZEOF (handlers); h++)
{
enum iconv_ilseq_handler handler = handlers[h];
static const uint16_t input[] = /* Ärger mit bösen Bübchen ohne Augenmaß */
}
/* Test conversion from UTF-16 to ISO-8859-1 with EILSEQ. */
- for (h = 0; h < SIZEOF (handlers); h++)
+ for (size_t h = 0; h < SIZEOF (handlers); h++)
{
enum iconv_ilseq_handler handler = handlers[h];
static const uint16_t input[] = /* Rafał Maszkowski */
# if 0
/* Test conversion from UTF-16 to ISO-8859-1 with EINVAL. */
- for (h = 0; h < SIZEOF (handlers); h++)
+ for (size_t h = 0; h < SIZEOF (handlers); h++)
{
enum iconv_ilseq_handler handler = handlers[h];
static const uint16_t input[] = { 0xD845, 0 };
#if HAVE_ICONV
static enum iconv_ilseq_handler handlers[] =
{ iconveh_error, iconveh_question_mark, iconveh_escape_sequence };
- size_t h;
- size_t o;
- size_t i;
/* Assume that iconv() supports at least the encodings ASCII, ISO-8859-1,
ISO-8859-2, and UTF-8. */
/* Test conversion from ISO-8859-1 to UTF-16 with no errors. */
- for (h = 0; h < SIZEOF (handlers); h++)
+ for (size_t h = 0; h < SIZEOF (handlers); h++)
{
enum iconv_ilseq_handler handler = handlers[h];
static const char input[] = "\304rger mit b\366sen B\374bchen ohne Augenma\337";
'e', 'n', ' ', 'B', 0xFC, 'b', 'c', 'h', 'e', 'n', ' ', 'o', 'h',
'n', 'e', ' ', 'A', 'u', 'g', 'e', 'n', 'm', 'a', 0xDF
};
- for (o = 0; o < 2; o++)
+ for (size_t o = 0; o < 2; o++)
{
size_t *offsets = (o ? new_offsets (strlen (input)) : NULL);
size_t length;
ASSERT (u32_cmp (result, expected, SIZEOF (expected)) == 0);
if (o)
{
- for (i = 0; i < 37; i++)
+ for (size_t i = 0; i < 37; i++)
ASSERT (offsets[i] == i);
ASSERT (offsets[37] == MAGIC);
free (offsets);
}
/* Test conversion from ISO-8859-2 to UTF-16 with no errors. */
- for (h = 0; h < SIZEOF (handlers); h++)
+ for (size_t h = 0; h < SIZEOF (handlers); h++)
{
enum iconv_ilseq_handler handler = handlers[h];
static const char input[] = "Rafa\263 Maszkowski"; /* Rafał Maszkowski */
'R', 'a', 'f', 'a', 0x0142, ' ', 'M', 'a', 's', 'z', 'k', 'o', 'w',
's', 'k', 'i'
};
- for (o = 0; o < 2; o++)
+ for (size_t o = 0; o < 2; o++)
{
size_t *offsets = (o ? new_offsets (strlen (input)) : NULL);
size_t length;
ASSERT (u32_cmp (result, expected, SIZEOF (expected)) == 0);
if (o)
{
- for (i = 0; i < 16; i++)
+ for (size_t i = 0; i < 16; i++)
ASSERT (offsets[i] == i);
ASSERT (offsets[16] == MAGIC);
free (offsets);
if (iconv_supports_encoding ("ISO-2022-JP-2"))
{
/* Test conversions from autodetect_jp to UTF-16. */
- for (h = 0; h < SIZEOF (handlers); h++)
+ for (size_t h = 0; h < SIZEOF (handlers); h++)
{
enum iconv_ilseq_handler handler = handlers[h];
static const char input[] = "\244\263\244\363\244\313\244\301\244\317"; /* こんにちは in EUC-JP */
{
0x3053, 0x3093, 0x306B, 0x3061, 0x306F
};
- for (o = 0; o < 2; o++)
+ for (size_t o = 0; o < 2; o++)
{
size_t *offsets = (o ? new_offsets (strlen (input)) : NULL);
size_t length;
ASSERT (u32_cmp (result, expected, SIZEOF (expected)) == 0);
if (o)
{
- for (i = 0; i < 10; i++)
+ for (size_t i = 0; i < 10; i++)
ASSERT (offsets[i] == ((i % 2) == 0 ? i / 2 : (size_t)(-1)));
ASSERT (offsets[10] == MAGIC);
free (offsets);
free (result);
}
}
- for (h = 0; h < SIZEOF (handlers); h++)
+ for (size_t h = 0; h < SIZEOF (handlers); h++)
{
enum iconv_ilseq_handler handler = handlers[h];
static const char input[] = "\202\261\202\361\202\311\202\277\202\315"; /* こんにちは in Shift_JIS */
{
0x3053, 0x3093, 0x306B, 0x3061, 0x306F
};
- for (o = 0; o < 2; o++)
+ for (size_t o = 0; o < 2; o++)
{
size_t *offsets = (o ? new_offsets (strlen (input)) : NULL);
size_t length;
ASSERT (u32_cmp (result, expected, SIZEOF (expected)) == 0);
if (o)
{
- for (i = 0; i < 10; i++)
+ for (size_t i = 0; i < 10; i++)
ASSERT (offsets[i] == ((i % 2) == 0 ? i / 2 : (size_t)(-1)));
ASSERT (offsets[10] == MAGIC);
free (offsets);
free (result);
}
}
- for (h = 0; h < SIZEOF (handlers); h++)
+ for (size_t h = 0; h < SIZEOF (handlers); h++)
{
enum iconv_ilseq_handler handler = handlers[h];
static const char input[] = "\033$B$3$s$K$A$O\033(B"; /* こんにちは in ISO-2022-JP-2 */
{
0x3053, 0x3093, 0x306B, 0x3061, 0x306F
};
- for (o = 0; o < 2; o++)
+ for (size_t o = 0; o < 2; o++)
{
size_t *offsets = (o ? new_offsets (strlen (input)) : NULL);
size_t length;
ASSERT (u32_cmp (result, expected, SIZEOF (expected)) == 0);
if (o)
{
- for (i = 0; i < 16; i++)
+ for (size_t i = 0; i < 16; i++)
ASSERT (offsets[i] == (i == 0 ? 0 :
i == 5 ? 1 :
i == 7 ? 2 :
#if HAVE_ICONV
static enum iconv_ilseq_handler handlers[] =
{ iconveh_error, iconveh_question_mark, iconveh_escape_sequence };
- size_t h;
- size_t o;
- size_t i;
/* Assume that iconv() supports at least the encodings ASCII, ISO-8859-1,
ISO-8859-2, and UTF-8. */
/* Test conversion from UTF-32 to ISO-8859-1 with no errors. */
- for (h = 0; h < SIZEOF (handlers); h++)
+ for (size_t h = 0; h < SIZEOF (handlers); h++)
{
enum iconv_ilseq_handler handler = handlers[h];
static const uint32_t input[] = /* Ärger mit bösen Bübchen ohne Augenmaß */
'n', 'e', ' ', 'A', 'u', 'g', 'e', 'n', 'm', 'a', 0xDF
};
static const char expected[] = "\304rger mit b\366sen B\374bchen ohne Augenma\337";
- for (o = 0; o < 2; o++)
+ for (size_t o = 0; o < 2; o++)
{
size_t *offsets = (o ? new_offsets (SIZEOF (input)) : NULL);
size_t length;
ASSERT (memcmp (result, expected, length) == 0);
if (o)
{
- for (i = 0; i < 37; i++)
+ for (size_t i = 0; i < 37; i++)
ASSERT (offsets[i] == i);
ASSERT (offsets[37] == MAGIC);
free (offsets);
}
/* Test conversion from UTF-32 to ISO-8859-1 with EILSEQ. */
- for (h = 0; h < SIZEOF (handlers); h++)
+ for (size_t h = 0; h < SIZEOF (handlers); h++)
{
enum iconv_ilseq_handler handler = handlers[h];
static const uint32_t input[] = /* Rafał Maszkowski */
'R', 'a', 'f', 'a', 0x0142, ' ', 'M', 'a', 's', 'z', 'k', 'o', 'w',
's', 'k', 'i'
};
- for (o = 0; o < 2; o++)
+ for (size_t o = 0; o < 2; o++)
{
size_t *offsets = (o ? new_offsets (SIZEOF (input)) : NULL);
size_t length = 0xdead;
|| memcmp (result, expected_translit, length) == 0);
if (o)
{
- for (i = 0; i < 16; i++)
+ for (size_t i = 0; i < 16; i++)
ASSERT (offsets[i] == i);
ASSERT (offsets[16] == MAGIC);
free (offsets);
ASSERT (memcmp (result, expected, length) == 0);
if (o)
{
- for (i = 0; i < 16; i++)
+ for (size_t i = 0; i < 16; i++)
ASSERT (offsets[i] == (i < 5 ? i : i + 5));
ASSERT (offsets[16] == MAGIC);
free (offsets);
#if HAVE_ICONV
static enum iconv_ilseq_handler handlers[] =
{ iconveh_error, iconveh_question_mark, iconveh_escape_sequence };
- size_t h;
/* Assume that iconv() supports at least the encodings ASCII, ISO-8859-1,
ISO-8859-2, and UTF-8. */
/* Test conversion from ISO-8859-1 to UTF-16 with no errors. */
- for (h = 0; h < SIZEOF (handlers); h++)
+ for (size_t h = 0; h < SIZEOF (handlers); h++)
{
enum iconv_ilseq_handler handler = handlers[h];
static const char input[] = "\304rger mit b\366sen B\374bchen ohne Augenma\337";
}
/* Test conversion from ISO-8859-2 to UTF-16 with no errors. */
- for (h = 0; h < SIZEOF (handlers); h++)
+ for (size_t h = 0; h < SIZEOF (handlers); h++)
{
enum iconv_ilseq_handler handler = handlers[h];
static const char input[] = "Rafa\263 Maszkowski"; /* Rafał Maszkowski */
if (iconv_supports_encoding ("ISO-2022-JP-2"))
{
/* Test conversions from autodetect_jp to UTF-16. */
- for (h = 0; h < SIZEOF (handlers); h++)
+ for (size_t h = 0; h < SIZEOF (handlers); h++)
{
enum iconv_ilseq_handler handler = handlers[h];
static const char input[] = "\244\263\244\363\244\313\244\301\244\317"; /* こんにちは in EUC-JP */
ASSERT (u32_strcmp (result, expected) == 0);
free (result);
}
- for (h = 0; h < SIZEOF (handlers); h++)
+ for (size_t h = 0; h < SIZEOF (handlers); h++)
{
enum iconv_ilseq_handler handler = handlers[h];
static const char input[] = "\202\261\202\361\202\311\202\277\202\315"; /* こんにちは in Shift_JIS */
ASSERT (u32_strcmp (result, expected) == 0);
free (result);
}
- for (h = 0; h < SIZEOF (handlers); h++)
+ for (size_t h = 0; h < SIZEOF (handlers); h++)
{
enum iconv_ilseq_handler handler = handlers[h];
static const char input[] = "\033$B$3$s$K$A$O\033(B"; /* こんにちは in ISO-2022-JP-2 */
#if HAVE_ICONV
static enum iconv_ilseq_handler handlers[] =
{ iconveh_error, iconveh_question_mark, iconveh_escape_sequence };
- size_t h;
/* Assume that iconv() supports at least the encodings ASCII, ISO-8859-1,
ISO-8859-2, and UTF-8. */
/* Test conversion from UTF-32 to ISO-8859-1 with no errors. */
- for (h = 0; h < SIZEOF (handlers); h++)
+ for (size_t h = 0; h < SIZEOF (handlers); h++)
{
enum iconv_ilseq_handler handler = handlers[h];
static const uint32_t input[] = /* Ärger mit bösen Bübchen ohne Augenmaß */
}
/* Test conversion from UTF-32 to ISO-8859-1 with EILSEQ. */
- for (h = 0; h < SIZEOF (handlers); h++)
+ for (size_t h = 0; h < SIZEOF (handlers); h++)
{
enum iconv_ilseq_handler handler = handlers[h];
static const uint32_t input[] = /* Rafał Maszkowski */
#if HAVE_ICONV
static enum iconv_ilseq_handler handlers[] =
{ iconveh_error, iconveh_question_mark, iconveh_escape_sequence };
- size_t h;
- size_t o;
- size_t i;
/* Assume that iconv() supports at least the encodings ASCII, ISO-8859-1,
ISO-8859-2, and UTF-8. */
/* Test conversion from ISO-8859-1 to UTF-8 with no errors. */
- for (h = 0; h < SIZEOF (handlers); h++)
+ for (size_t h = 0; h < SIZEOF (handlers); h++)
{
enum iconv_ilseq_handler handler = handlers[h];
static const char input[] = "\304rger mit b\366sen B\374bchen ohne Augenma\337";
static const uint8_t expected[] = "\303\204rger mit b\303\266sen B\303\274bchen ohne Augenma\303\237";
- for (o = 0; o < 2; o++)
+ for (size_t o = 0; o < 2; o++)
{
size_t *offsets = (o ? new_offsets (strlen (input)) : NULL);
size_t length;
ASSERT (u8_cmp (result, expected, u8_strlen (expected)) == 0);
if (o)
{
- for (i = 0; i < 37; i++)
+ for (size_t i = 0; i < 37; i++)
ASSERT (offsets[i] == (i < 1 ? i :
i < 12 ? i + 1 :
i < 18 ? i + 2 :
}
/* Test conversion from ISO-8859-2 to UTF-8 with no errors. */
- for (h = 0; h < SIZEOF (handlers); h++)
+ for (size_t h = 0; h < SIZEOF (handlers); h++)
{
enum iconv_ilseq_handler handler = handlers[h];
static const char input[] = "Rafa\263 Maszkowski"; /* Rafał Maszkowski */
static const uint8_t expected[] = "Rafa\305\202 Maszkowski";
- for (o = 0; o < 2; o++)
+ for (size_t o = 0; o < 2; o++)
{
size_t *offsets = (o ? new_offsets (strlen (input)) : NULL);
size_t length;
ASSERT (u8_cmp (result, expected, u8_strlen (expected)) == 0);
if (o)
{
- for (i = 0; i < 16; i++)
+ for (size_t i = 0; i < 16; i++)
ASSERT (offsets[i] == (i < 5 ? i :
i + 1));
ASSERT (offsets[16] == MAGIC);
if (iconv_supports_encoding ("ISO-2022-JP-2"))
{
/* Test conversions from autodetect_jp to UTF-8. */
- for (h = 0; h < SIZEOF (handlers); h++)
+ for (size_t h = 0; h < SIZEOF (handlers); h++)
{
enum iconv_ilseq_handler handler = handlers[h];
static const char input[] = "\244\263\244\363\244\313\244\301\244\317"; /* こんにちは in EUC-JP */
static const uint8_t expected[] = "\343\201\223\343\202\223\343\201\253\343\201\241\343\201\257"; /* こんにちは */
- for (o = 0; o < 2; o++)
+ for (size_t o = 0; o < 2; o++)
{
size_t *offsets = (o ? new_offsets (strlen (input)) : NULL);
size_t length;
ASSERT (u8_cmp (result, expected, u8_strlen (expected)) == 0);
if (o)
{
- for (i = 0; i < 10; i++)
+ for (size_t i = 0; i < 10; i++)
ASSERT (offsets[i] == ((i % 2) == 0 ? (i / 2) * 3 : (size_t)(-1)));
ASSERT (offsets[10] == MAGIC);
free (offsets);
free (result);
}
}
- for (h = 0; h < SIZEOF (handlers); h++)
+ for (size_t h = 0; h < SIZEOF (handlers); h++)
{
enum iconv_ilseq_handler handler = handlers[h];
static const char input[] = "\202\261\202\361\202\311\202\277\202\315"; /* こんにちは in Shift_JIS */
static const uint8_t expected[] = "\343\201\223\343\202\223\343\201\253\343\201\241\343\201\257"; /* こんにちは */
- for (o = 0; o < 2; o++)
+ for (size_t o = 0; o < 2; o++)
{
size_t *offsets = (o ? new_offsets (strlen (input)) : NULL);
size_t length;
ASSERT (u8_cmp (result, expected, u8_strlen (expected)) == 0);
if (o)
{
- for (i = 0; i < 10; i++)
+ for (size_t i = 0; i < 10; i++)
ASSERT (offsets[i] == ((i % 2) == 0 ? (i / 2) * 3 : (size_t)(-1)));
ASSERT (offsets[10] == MAGIC);
free (offsets);
free (result);
}
}
- for (h = 0; h < SIZEOF (handlers); h++)
+ for (size_t h = 0; h < SIZEOF (handlers); h++)
{
enum iconv_ilseq_handler handler = handlers[h];
static const char input[] = "\033$B$3$s$K$A$O\033(B"; /* こんにちは in ISO-2022-JP-2 */
static const uint8_t expected[] = "\343\201\223\343\202\223\343\201\253\343\201\241\343\201\257"; /* こんにちは */
- for (o = 0; o < 2; o++)
+ for (size_t o = 0; o < 2; o++)
{
size_t *offsets = (o ? new_offsets (strlen (input)) : NULL);
size_t length;
ASSERT (u8_cmp (result, expected, u8_strlen (expected)) == 0);
if (o)
{
- for (i = 0; i < 16; i++)
+ for (size_t i = 0; i < 16; i++)
ASSERT (offsets[i] == (i == 0 ? 0 :
i == 5 ? 3 :
i == 7 ? 6 :
#if HAVE_ICONV
static enum iconv_ilseq_handler handlers[] =
{ iconveh_error, iconveh_question_mark, iconveh_escape_sequence };
- size_t h;
- size_t o;
- size_t i;
/* Assume that iconv() supports at least the encodings ASCII, ISO-8859-1,
ISO-8859-2, and UTF-8. */
/* Test conversion from UTF-8 to ISO-8859-1 with no errors. */
- for (h = 0; h < SIZEOF (handlers); h++)
+ for (size_t h = 0; h < SIZEOF (handlers); h++)
{
enum iconv_ilseq_handler handler = handlers[h];
static const uint8_t input[] = "\303\204rger mit b\303\266sen B\303\274bchen ohne Augenma\303\237";
static const char expected[] = "\304rger mit b\366sen B\374bchen ohne Augenma\337";
- for (o = 0; o < 2; o++)
+ for (size_t o = 0; o < 2; o++)
{
size_t *offsets = (o ? new_offsets (u8_strlen (input)) : NULL);
size_t length;
ASSERT (memcmp (result, expected, length) == 0);
if (o)
{
- for (i = 0; i < 41; i++)
+ for (size_t i = 0; i < 41; i++)
ASSERT (offsets[i] == (i < 1 ? i :
i == 1 ? (size_t)(-1) :
i < 13 ? i - 1 :
}
/* Test conversion from UTF-8 to ISO-8859-1 with EILSEQ. */
- for (h = 0; h < SIZEOF (handlers); h++)
+ for (size_t h = 0; h < SIZEOF (handlers); h++)
{
enum iconv_ilseq_handler handler = handlers[h];
static const uint8_t input[] = "Rafa\305\202 Maszkowski"; /* Rafał Maszkowski */
- for (o = 0; o < 2; o++)
+ for (size_t o = 0; o < 2; o++)
{
size_t *offsets = (o ? new_offsets (u8_strlen (input)) : NULL);
size_t length = 0xdead;
|| memcmp (result, expected_translit, length) == 0);
if (o)
{
- for (i = 0; i < 17; i++)
+ for (size_t i = 0; i < 17; i++)
ASSERT (offsets[i] == (i < 5 ? i :
i == 5 ? (size_t)(-1) :
i - 1));
ASSERT (memcmp (result, expected, length) == 0);
if (o)
{
- for (i = 0; i < 17; i++)
+ for (size_t i = 0; i < 17; i++)
ASSERT (offsets[i] == (i < 5 ? i :
i == 5 ? (size_t)(-1) :
i + 4));
}
/* Test conversion from UTF-8 to ISO-8859-1 with EINVAL. */
- for (h = 0; h < SIZEOF (handlers); h++)
+ for (size_t h = 0; h < SIZEOF (handlers); h++)
{
enum iconv_ilseq_handler handler = handlers[h];
static const uint8_t input[] = "\342";
- for (o = 0; o < 2; o++)
+ for (size_t o = 0; o < 2; o++)
{
size_t *offsets = (o ? new_offsets (u8_strlen (input)) : NULL);
size_t length;
#if HAVE_ICONV
static enum iconv_ilseq_handler handlers[] =
{ iconveh_error, iconveh_question_mark, iconveh_escape_sequence };
- size_t h;
/* Assume that iconv() supports at least the encodings ASCII, ISO-8859-1,
ISO-8859-2, and UTF-8. */
/* Test conversion from ISO-8859-1 to UTF-8 with no errors. */
- for (h = 0; h < SIZEOF (handlers); h++)
+ for (size_t h = 0; h < SIZEOF (handlers); h++)
{
enum iconv_ilseq_handler handler = handlers[h];
static const char input[] = "\304rger mit b\366sen B\374bchen ohne Augenma\337";
}
/* Test conversion from ISO-8859-2 to UTF-8 with no errors. */
- for (h = 0; h < SIZEOF (handlers); h++)
+ for (size_t h = 0; h < SIZEOF (handlers); h++)
{
enum iconv_ilseq_handler handler = handlers[h];
static const char input[] = "Rafa\263 Maszkowski"; /* Rafał Maszkowski */
if (iconv_supports_encoding ("ISO-2022-JP-2"))
{
/* Test conversions from autodetect_jp to UTF-8. */
- for (h = 0; h < SIZEOF (handlers); h++)
+ for (size_t h = 0; h < SIZEOF (handlers); h++)
{
enum iconv_ilseq_handler handler = handlers[h];
static const char input[] = "\244\263\244\363\244\313\244\301\244\317"; /* こんにちは in EUC-JP */
ASSERT (u8_strcmp (result, expected) == 0);
free (result);
}
- for (h = 0; h < SIZEOF (handlers); h++)
+ for (size_t h = 0; h < SIZEOF (handlers); h++)
{
enum iconv_ilseq_handler handler = handlers[h];
static const char input[] = "\202\261\202\361\202\311\202\277\202\315"; /* こんにちは in Shift_JIS */
ASSERT (u8_strcmp (result, expected) == 0);
free (result);
}
- for (h = 0; h < SIZEOF (handlers); h++)
+ for (size_t h = 0; h < SIZEOF (handlers); h++)
{
enum iconv_ilseq_handler handler = handlers[h];
static const char input[] = "\033$B$3$s$K$A$O\033(B"; /* こんにちは in ISO-2022-JP-2 */
#if HAVE_ICONV
static enum iconv_ilseq_handler handlers[] =
{ iconveh_error, iconveh_question_mark, iconveh_escape_sequence };
- size_t h;
/* Assume that iconv() supports at least the encodings ASCII, ISO-8859-1,
ISO-8859-2, and UTF-8. */
/* Test conversion from UTF-8 to ISO-8859-1 with no errors. */
- for (h = 0; h < SIZEOF (handlers); h++)
+ for (size_t h = 0; h < SIZEOF (handlers); h++)
{
enum iconv_ilseq_handler handler = handlers[h];
static const uint8_t input[] = "\303\204rger mit b\303\266sen B\303\274bchen ohne Augenma\303\237";
}
/* Test conversion from UTF-8 to ISO-8859-1 with EILSEQ. */
- for (h = 0; h < SIZEOF (handlers); h++)
+ for (size_t h = 0; h < SIZEOF (handlers); h++)
{
enum iconv_ilseq_handler handler = handlers[h];
static const uint8_t input[] = "Rafa\305\202 Maszkowski"; /* Rafał Maszkowski */
# if 0
/* Test conversion from UTF-8 to ISO-8859-1 with EINVAL. */
- for (h = 0; h < SIZEOF (handlers); h++)
+ for (size_t h = 0; h < SIZEOF (handlers); h++)
{
enum iconv_ilseq_handler handler = handlers[h];
static const uint8_t input[] = "\342";
ASSERT (!uc_is_bidi_class ('7', UC_BIDI_L));
ASSERT (!uc_is_bidi_class ('7', UC_BIDI_R));
- {
- unsigned int c;
-
- for (c = 0; c < 0x110000; c++)
- ASSERT (uc_is_bidi_class (c, uc_bidi_class (c)));
- }
+ for (unsigned int c = 0; c < 0x110000; c++)
+ ASSERT (uc_is_bidi_class (c, uc_bidi_class (c)));
return test_exit_status;
}
{
const uc_block_t *latin_block = NULL;
const uc_block_t *hebrew_block = NULL;
- size_t i;
- for (i = 0; i < nblocks; i++)
+ for (size_t i = 0; i < nblocks; i++)
{
if (strcmp (blocks[i].name, "Latin") == 0)
latin_block = &blocks[i];
ASSERT (strcmp (uc_block ('x')->name, "Basic Latin") == 0);
ASSERT (strcmp (uc_block (0x20AC)->name, "Currency Symbols") == 0);
- {
- unsigned int c;
-
- for (c = 0; c < 0x110000; c++)
- {
- const uc_block_t *block = uc_block (c);
- ASSERT (block == NULL || uc_is_block (c, block));
- }
- }
+ for (unsigned int c = 0; c < 0x110000; c++)
+ {
+ const uc_block_t *block = uc_block (c);
+ ASSERT (block == NULL || uc_is_block (c, block));
+ }
{
const uc_block_t *blocks;
size_t nblocks;
- size_t i;
uc_all_blocks (&blocks, &nblocks);
- for (i = 0; i < nblocks; i++)
+ for (size_t i = 0; i < nblocks; i++)
{
if (strcmp (blocks[i].name, "Hebrew") == 0)
{
}
}
- for (i = 0; i < nblocks; i++)
+ for (size_t i = 0; i < nblocks; i++)
{
- unsigned int c;
-
- for (c = blocks[i].start; c <= blocks[i].end; c++)
+ for (unsigned int c = blocks[i].start; c <= blocks[i].end; c++)
ASSERT (uc_block (c) == &blocks[i]);
}
}
{
uc_general_category_t ct = uc_general_category_byname ("Nd");
- unsigned int c;
- for (c = 0x30; c <= 0x39; c++)
+ for (unsigned int c = 0x30; c <= 0x39; c++)
ASSERT (uc_is_general_category (c, ct));
- for (c = 0x40; c < 0x80; c++)
+ for (unsigned int c = 0x40; c < 0x80; c++)
ASSERT (!uc_is_general_category (c, ct));
}
{
uc_general_category_t ct = uc_general_category_byname ("Nl");
- unsigned int c;
- for (c = 0x2160; c < 0x2180; c++)
+ for (unsigned int c = 0x2160; c < 0x2180; c++)
ASSERT (uc_is_general_category (c, ct));
ASSERT (!uc_is_general_category (0x0BF1, ct));
ASSERT (!uc_is_general_category (0x0D71, ct));
{
uc_general_category_t ct = uc_general_category_byname ("Foo");
- unsigned int c;
- for (c = 0; c < 0x110000; c++)
+ for (unsigned int c = 0; c < 0x110000; c++)
ASSERT (!uc_is_general_category (c, ct));
}
#if !defined _MSC_VER
uc_general_category_t ct = _UC_CATEGORY_NONE;
- unsigned int c;
- for (c = 0; c < 0x110000; c++)
+ for (unsigned int c = 0; c < 0x110000; c++)
ASSERT (!uc_is_general_category (c, ct));
#endif
int
main ()
{
- {
- unsigned int c;
- for (c = 0; c < 0x110000; c++)
- ASSERT (uc_is_general_category (c, uc_general_category (c)));
- }
+ for (unsigned int c = 0; c < 0x110000; c++)
+ ASSERT (uc_is_general_category (c, uc_general_category (c)));
{
uc_general_category_t decimal_digits = uc_general_category ('7');
- unsigned int c;
- for (c = 0x30; c <= 0x39; c++)
+ for (unsigned int c = 0x30; c <= 0x39; c++)
ASSERT (uc_is_general_category (c, decimal_digits));
- for (c = 0x40; c < 0x80; c++)
+ for (unsigned int c = 0x40; c < 0x80; c++)
ASSERT (!uc_is_general_category (c, decimal_digits));
}
{
uc_general_category_t lowercase_letters = uc_general_category ('x');
- unsigned int c;
- for (c = 0x41; c <= 0x5A; c++)
+ for (unsigned int c = 0x41; c <= 0x5A; c++)
ASSERT (!uc_is_general_category (c, lowercase_letters));
- for (c = 0x61; c <= 0x7A; c++)
+ for (unsigned int c = 0x61; c <= 0x7A; c++)
ASSERT (uc_is_general_category (c, lowercase_letters));
}
main ()
{
unsigned int c;
- size_t i;
c = 0;
- for (i = 0; i < SIZEOF (mapping); i++)
+ for (size_t i = 0; i < SIZEOF (mapping); i++)
{
for (; c < mapping[i].ch; c++)
ASSERT (uc_decimal_value (c) == -1);
main ()
{
unsigned int c;
- size_t i;
c = 0;
- for (i = 0; i < SIZEOF (mapping); i++)
+ for (size_t i = 0; i < SIZEOF (mapping); i++)
{
for (; c < mapping[i].ch; c++)
ASSERT (uc_digit_value (c) == -1);
main ()
{
unsigned int c;
- size_t i;
c = 0;
- for (i = 0; i < SIZEOF (mapping); i++)
+ for (size_t i = 0; i < SIZEOF (mapping); i++)
{
for (; c < mapping[i].ch; c++)
ASSERT (uc_indic_conjunct_break (c) == UC_INDIC_CONJUNCT_BREAK_NONE);
main ()
{
unsigned int c;
- size_t i;
c = 0;
- for (i = 0; i < SIZEOF (mapping); i++)
+ for (size_t i = 0; i < SIZEOF (mapping); i++)
{
for (; c < mapping[i].ch; c++)
ASSERT (uc_joining_group (c) == UC_JOINING_GROUP_NONE);
main ()
{
unsigned int c;
- size_t i;
c = 0;
- for (i = 0; i < SIZEOF (mapping); i++)
+ for (size_t i = 0; i < SIZEOF (mapping); i++)
{
for (; c < mapping[i].ch; c++)
ASSERT (uc_joining_type (c) == UC_JOINING_TYPE_U
{
unsigned int c;
uc_fraction_t value;
- size_t i;
c = 0;
- for (i = 0; i < SIZEOF (mapping); i++)
+ for (size_t i = 0; i < SIZEOF (mapping); i++)
{
for (; c < mapping[i].ch; c++)
{
{
{
uc_property_t pr = uc_property_byname ("composite");
- unsigned int c;
- for (c = 0; c < 0x110000; c++)
+ for (unsigned int c = 0; c < 0x110000; c++)
ASSERT (uc_is_property (c, pr) == uc_is_property_composite (c));
}
main ()
{
uc_property_t pr = UC_PROPERTY_COMPOSITE;
- unsigned int c;
- for (c = 0; c < 0x110000; c++)
+ for (unsigned int c = 0; c < 0x110000; c++)
ASSERT (uc_is_property (c, pr) == uc_is_property_composite (c));
return test_exit_status;
main ()
{
unsigned int c;
- size_t i;
c = 0;
- for (i = 0; i < SIZEOF (set); i++)
+ for (size_t i = 0; i < SIZEOF (set); i++)
{
for (; c < set[i].start; c++)
ASSERT (!PREDICATE (c));
ASSERT (!uc_is_script (0x05DA, uc_script_byname ("Latin")));
ASSERT (uc_is_script (0x05DA, uc_script_byname ("Hebrew")));
- {
- unsigned int c;
-
- for (c = 0; c < 0x110000; c++)
- {
- const uc_script_t *script = uc_script (c);
- if (script != NULL)
- ASSERT (uc_is_script (c, script));
- }
- }
+ for (unsigned int c = 0; c < 0x110000; c++)
+ {
+ const uc_script_t *script = uc_script (c);
+ if (script != NULL)
+ ASSERT (uc_is_script (c, script));
+ }
/* Test the uc_all_scripts function. */
{
const uc_script_t *scripts;
size_t nscripts;
- size_t i;
bool found;
uc_all_scripts (&scripts, &nscripts);
found = false;
- for (i = 0; i < nscripts; i++)
+ for (size_t i = 0; i < nscripts; i++)
{
ASSERT (scripts[i].name != NULL);
if (strcmp (scripts[i].name, "Hebrew") == 0)
uint16_t s[16];
va_list args;
char breaks[16];
- size_t i;
ASSERT (n <= 16);
memset (breaks, 0xcc, n);
va_start (args, expected);
- for (i = 0; i < n; i++)
+ for (size_t i = 0; i < n; i++)
{
int unit = va_arg (args, int);
ASSERT (unit >= 0);
va_end (args);
u16_grapheme_breaks (s, n, breaks);
- for (i = 0; i < n; i++)
+ for (size_t i = 0; i < n; i++)
if (breaks[i] != (expected[i] == '#'))
{
- size_t j;
-
fprintf (stderr, "wrong grapheme breaks:\n");
fprintf (stderr, " input:");
- for (j = 0; j < n; j++)
+ for (size_t j = 0; j < n; j++)
fprintf (stderr, " %04X", s[j]);
putc ('\n', stderr);
fprintf (stderr, "expected:");
- for (j = 0; j < n; j++)
+ for (size_t j = 0; j < n; j++)
fprintf (stderr, " %d", expected[j] == '#');
putc ('\n', stderr);
fprintf (stderr, " actual:");
- for (j = 0; j < n; j++)
+ for (size_t j = 0; j < n; j++)
fprintf (stderr, " %d", breaks[j]);
putc ('\n', stderr);
next = u16_grapheme_next (s, s + n);
if (next != s + len)
{
- size_t i;
-
if (next == NULL)
fputs ("u16_grapheme_next returned NULL", stderr);
else
fprintf (stderr, "u16_grapheme_next skipped %tu units", next - s);
fprintf (stderr, ", expected %zu:\n", len);
- for (i = 0; i < n; i++)
+ for (size_t i = 0; i < n; i++)
fprintf (stderr, " %04x", s[i]);
putc ('\n', stderr);
fflush (stderr);
prev = u16_grapheme_prev (end, s);
if (prev != end - len)
{
- size_t i;
-
if (prev == NULL)
fputs ("u16_grapheme_prev returned NULL", stderr);
else
fprintf (stderr, "u16_grapheme_prev skipped %tu units", end - prev);
fprintf (stderr, ", expected %zu:\n", len);
- for (i = 0; i < n; i++)
+ for (size_t i = 0; i < n; i++)
fprintf (stderr, " %04x", s[i]);
putc ('\n', stderr);
fflush (stderr);
uint32_t s[16];
va_list args;
char breaks[16];
- size_t i;
ASSERT (n <= 16);
memset (breaks, 0xcc, n);
va_start (args, expected);
- for (i = 0; i < n; i++)
+ for (size_t i = 0; i < n; i++)
{
int unit = va_arg (args, int);
ASSERT (unit >= 0);
va_end (args);
u32_grapheme_breaks (s, n, breaks);
- for (i = 0; i < n; i++)
+ for (size_t i = 0; i < n; i++)
if (breaks[i] != (expected[i] == '#'))
{
- size_t j;
-
fprintf (stderr, "wrong grapheme breaks:\n");
fprintf (stderr, " input:");
- for (j = 0; j < n; j++)
+ for (size_t j = 0; j < n; j++)
fprintf (stderr, " %04X", s[j]);
putc ('\n', stderr);
fprintf (stderr, "expected:");
- for (j = 0; j < n; j++)
+ for (size_t j = 0; j < n; j++)
fprintf (stderr, " %d", expected[j] == '#');
putc ('\n', stderr);
fprintf (stderr, " actual:");
- for (j = 0; j < n; j++)
+ for (size_t j = 0; j < n; j++)
fprintf (stderr, " %d", breaks[j]);
putc ('\n', stderr);
next = u32_grapheme_next (s, s + n);
if (next != s + len)
{
- size_t i;
-
if (next == NULL)
fputs ("u32_grapheme_next returned NULL", stderr);
else
fprintf (stderr, "u32_grapheme_next skipped %tu units", next - s);
fprintf (stderr, ", expected %zu:\n", len);
- for (i = 0; i < n; i++)
+ for (size_t i = 0; i < n; i++)
fprintf (stderr, " %04x", s[i]);
putc ('\n', stderr);
fflush (stderr);
prev = u32_grapheme_prev (end, s);
if (prev != end - len)
{
- size_t i;
-
if (prev == NULL)
fputs ("u32_grapheme_prev returned NULL", stderr);
else
fprintf (stderr, "u32_grapheme_prev skipped %tu units", end - prev);
fprintf (stderr, ", expected %zu:\n", len);
- for (i = 0; i < n; i++)
+ for (size_t i = 0; i < n; i++)
fprintf (stderr, " %04x", s[i]);
putc ('\n', stderr);
fflush (stderr);
const uint8_t *s = (const uint8_t *) input;
size_t n = strlen (expected);
char *breaks;
- size_t i;
breaks = malloc (n);
if (!breaks)
memset (breaks, 0xcc, n);
u8_grapheme_breaks (s, n, breaks);
- for (i = 0; i < n; i++)
+ for (size_t i = 0; i < n; i++)
if (breaks[i] != (expected[i] == '#'))
{
- size_t j;
-
fprintf (stderr, "wrong grapheme breaks:\n");
fprintf (stderr, " input:");
- for (j = 0; j < n; j++)
+ for (size_t j = 0; j < n; j++)
fprintf (stderr, " %02X", s[j]);
putc ('\n', stderr);
fprintf (stderr, "expected:");
- for (j = 0; j < n; j++)
+ for (size_t j = 0; j < n; j++)
fprintf (stderr, " %d", expected[j] == '#');
putc ('\n', stderr);
fprintf (stderr, " actual:");
- for (j = 0; j < n; j++)
+ for (size_t j = 0; j < n; j++)
fprintf (stderr, " %d", breaks[j]);
putc ('\n', stderr);
const uint8_t *next = u8_grapheme_next (s, s + n);
if (next != s + len)
{
- size_t i;
-
if (next == NULL)
fputs ("u8_grapheme_next returned NULL", stderr);
else
fprintf (stderr, "u8_grapheme_next skipped %tu bytes", next - s);
fprintf (stderr, ", expected %zu:\n", len);
- for (i = 0; i < n; i++)
+ for (size_t i = 0; i < n; i++)
fprintf (stderr, " %02x", s[i]);
putc ('\n', stderr);
fflush (stderr);
const uint8_t *prev = u8_grapheme_prev (end, s);
if (prev != end - len)
{
- size_t i;
-
if (prev == NULL)
fputs ("u8_grapheme_prev returned NULL", stderr);
else
fprintf (stderr, "u8_grapheme_prev skipped %tu bytes", end - prev);
fprintf (stderr, ", expected %zu:\n", len);
- for (i = 0; i < n; i++)
+ for (size_t i = 0; i < n; i++)
fprintf (stderr, " %02x", s[i]);
putc ('\n', stderr);
fflush (stderr);
int
main (void)
{
- const struct uc_gbrk_prop_range *r;
ucs4_t uc;
uc = 0;
- for (r = set; r < set + SIZEOF (set); r++)
+ for (const struct uc_gbrk_prop_range *r = set; r < set + SIZEOF (set); r++)
{
for (; uc < r->end; uc++)
{
const char *filename, int lineno)
{
char breaks[16];
- size_t i;
ASSERT (n <= 16);
uc_grapheme_breaks (s, n, breaks);
- for (i = 0; i < n; i++)
+ for (size_t i = 0; i < n; i++)
if (breaks[i] != (expected[i] == '#'))
{
- size_t j;
-
fprintf (stderr, "wrong grapheme breaks:\n");
fprintf (stderr, " input:");
- for (j = 0; j < n; j++)
+ for (size_t j = 0; j < n; j++)
fprintf (stderr, " %04X", s[j]);
putc ('\n', stderr);
fprintf (stderr, "expected:");
- for (j = 0; j < n; j++)
+ for (size_t j = 0; j < n; j++)
fprintf (stderr, " %d", expected[j] == '#');
putc ('\n', stderr);
fprintf (stderr, " actual:");
- for (j = 0; j < n; j++)
+ for (size_t j = 0; j < n; j++)
fprintf (stderr, " %d", breaks[j]);
putc ('\n', stderr);
static const char s[] = "ZYX\352\353W\360\361V\362";
enum { LENGTH = sizeof s - 1 };
char p[LENGTH];
- size_t i;
ulc_grapheme_breaks (s, LENGTH, p);
- for (i = 0; i < LENGTH; i++)
+ for (size_t i = 0; i < LENGTH; i++)
if (p[i] != is_8859_6_break (s[i]))
{
- size_t j;
-
fprintf (stderr, "wrong grapheme breaks:\n");
fprintf (stderr, " input:");
- for (j = 0; j < LENGTH; j++)
+ for (size_t j = 0; j < LENGTH; j++)
fprintf (stderr, " %02X", (unsigned char) s[j]);
putc ('\n', stderr);
fprintf (stderr, "expected:");
- for (j = 0; j < LENGTH; j++)
+ for (size_t j = 0; j < LENGTH; j++)
fprintf (stderr, " %d", is_8859_6_break (s[j]));
putc ('\n', stderr);
fprintf (stderr, " actual:");
- for (j = 0; j < LENGTH; j++)
+ for (size_t j = 0; j < LENGTH; j++)
fprintf (stderr, " %d", p[j]);
putc ('\n', stderr);
{
char *p = (char *) malloc (SIZEOF (input));
- size_t i;
my_u16_possible_linebreaks (input, SIZEOF (input), "GB18030", p);
- for (i = 0; i < 61; i++)
+ for (size_t i = 0; i < 61; i++)
{
ASSERT (p[i] == (i == 60 ? UC_BREAK_MANDATORY :
i == 5
{
char *p = (char *) malloc (SIZEOF (input));
- size_t i;
my_u16_possible_linebreaks (input, SIZEOF (input), "GB2312", p);
- for (i = 0; i < 61; i++)
+ for (size_t i = 0; i < 61; i++)
{
ASSERT (p[i] == (i == 60 ? UC_BREAK_MANDATORY :
i == 5
static const uint16_t input[8] =
{ 'a', '\n', 'b', '\r', 'c', '\r', '\n', 'd' };
char *p = (char *) malloc (SIZEOF (input));
- size_t i;
my_u16_possible_linebreaks (input, SIZEOF (input), "UTF-8", p);
- for (i = 0; i < 8; i++)
+ for (size_t i = 0; i < 8; i++)
{
ASSERT (p[i] == (i == 1 || i == 3 || i == 6 ? UC_BREAK_MANDATORY :
i == 5 ? (version < 2 ? UC_BREAK_MANDATORY : UC_BREAK_CR_BEFORE_LF) :
{
static const uint16_t input[4] = { 'x', 0x200B, ' ', 'y' };
char *p = (char *) malloc (SIZEOF (input));
- size_t i;
my_u16_possible_linebreaks (input, SIZEOF (input), "UTF-8", p);
- for (i = 0; i < 4; i++)
+ for (size_t i = 0; i < 4; i++)
{
ASSERT (p[i] == (i == 3 ? UC_BREAK_POSSIBLE : UC_BREAK_PROHIBITED));
}
'e', 'n', 'c', 'e', '.', '<', '/', 'P', '>'
};
char *p = (char *) malloc (SIZEOF (input));
- size_t i;
my_u16_possible_linebreaks (input, SIZEOF (input), "UTF-8", p);
- for (i = 0; i < 21; i++)
+ for (size_t i = 0; i < 21; i++)
{
ASSERT (p[i] == (i == 8 || i == 17 || i == 19 ? UC_BREAK_POSSIBLE :
UC_BREAK_PROHIBITED));
0x0300
};
char *p = (char *) malloc (SIZEOF (input));
- size_t i;
my_u16_possible_linebreaks (input, SIZEOF (input), "UTF-8", p);
- for (i = 0; i < 16; i++)
+ for (size_t i = 0; i < 16; i++)
{
ASSERT (p[i] == (i == 14 ? UC_BREAK_MANDATORY :
i == 6 || i == 9 || i == 11 ? UC_BREAK_POSSIBLE :
0x261D, 0x200D, 0xD83C, 0xDFFF, '\n',
};
char *p = (char *) malloc (SIZEOF (input));
- size_t i;
my_u16_possible_linebreaks (input, SIZEOF (input), "UTF-8", p);
- for (i = 0; i < 39; i++)
+ for (size_t i = 0; i < 39; i++)
{
ASSERT (p[i] == (i == 8 || i == 20
|| i == 24 || i == 29
static const uint16_t input[8] =
{ 0xD83C, 0xDDE9, 0xD83C, 0xDDEA, 0xD83C, 0xDDEB, 0xD83C, 0xDDF7 };
char *p = (char *) malloc (SIZEOF (input));
- size_t i;
my_u16_possible_linebreaks (input, SIZEOF (input), "UTF-8", p);
- for (i = 0; i < 8; i++)
+ for (size_t i = 0; i < 8; i++)
{
ASSERT (p[i] == (i == 4 ? UC_BREAK_POSSIBLE : UC_BREAK_PROHIBITED));
}
static const uint16_t input[10] = /* "ab-אב-αβ-ω" */
{ 'a', 'b', '-', 0x05D0, 0x05D1, '-', 0x03B1, 0x03B2, '-', 0x03C9 };
char *p = (char *) malloc (SIZEOF (input));
- size_t i;
my_u16_possible_linebreaks (input, SIZEOF (input), "UTF-8", p);
- for (i = 0; i < 10; i++)
+ for (size_t i = 0; i < 10; i++)
{
ASSERT (p[i] == (i == 3 || i == 9 ? UC_BREAK_POSSIBLE :
UC_BREAK_PROHIBITED));
'G', 0x300C, 0x30E6, 0x30CB, 0x30B3, 0x30FC, 0x30C9, 0x300D
};
char *p = (char *) malloc (SIZEOF (input));
- size_t i;
my_u16_possible_linebreaks (input, SIZEOF (input), "UTF-8", p);
- for (i = 0; i < 17; i++)
+ for (size_t i = 0; i < 17; i++)
{
ASSERT (p[i] == (i == 1 || i == 2 || i == 3 || i == 4 || i == 5
|| i == 6 || i == 7 || i == 8 || i == 9
{
static const uint16_t input[4] = { 0xD83F, 0xDFFC, 0xD83C, 0xDFFF };
char *p = (char *) malloc (SIZEOF (input));
- size_t i;
my_u16_possible_linebreaks (input, SIZEOF (input), "UTF-8", p);
- for (i = 0; i < 4; i++)
+ for (size_t i = 0; i < 4; i++)
{
ASSERT (p[i] == UC_BREAK_PROHIBITED);
}
{
char *p = (char *) malloc (SIZEOF (input));
- size_t i;
my_u16_width_linebreaks (input, SIZEOF (input), 25, 0, 0, NULL, "GB18030", p);
- for (i = 0; i < 61; i++)
+ for (size_t i = 0; i < 61; i++)
{
ASSERT (p[i] == (i == 60 ? UC_BREAK_MANDATORY :
i == 25 || i == 45 ? UC_BREAK_POSSIBLE :
{
char *p = (char *) malloc (SIZEOF (input));
- size_t i;
my_u16_width_linebreaks (input, SIZEOF (input), 25, 0, 0, NULL, "GB2312", p);
- for (i = 0; i < 61; i++)
+ for (size_t i = 0; i < 61; i++)
{
ASSERT (p[i] == (i == 60 ? UC_BREAK_MANDATORY :
i == 11 || i == 25 || i == 45 ? UC_BREAK_POSSIBLE :
{
char *p = (char *) malloc (SIZEOF (input));
- size_t i;
my_u32_possible_linebreaks (input, SIZEOF (input), "GB18030", p);
- for (i = 0; i < 61; i++)
+ for (size_t i = 0; i < 61; i++)
{
ASSERT (p[i] == (i == 60 ? UC_BREAK_MANDATORY :
i == 5
{
char *p = (char *) malloc (SIZEOF (input));
- size_t i;
my_u32_possible_linebreaks (input, SIZEOF (input), "GB2312", p);
- for (i = 0; i < 61; i++)
+ for (size_t i = 0; i < 61; i++)
{
ASSERT (p[i] == (i == 60 ? UC_BREAK_MANDATORY :
i == 5
static const uint32_t input[8] =
{ 'a', '\n', 'b', '\r', 'c', '\r', '\n', 'd' };
char *p = (char *) malloc (SIZEOF (input));
- size_t i;
my_u32_possible_linebreaks (input, SIZEOF (input), "UTF-8", p);
- for (i = 0; i < 8; i++)
+ for (size_t i = 0; i < 8; i++)
{
ASSERT (p[i] == (i == 1 || i == 3 || i == 6 ? UC_BREAK_MANDATORY :
i == 5 ? (version < 2 ? UC_BREAK_MANDATORY : UC_BREAK_CR_BEFORE_LF) :
{
static const uint32_t input[4] = { 'x', 0x200B, ' ', 'y' };
char *p = (char *) malloc (SIZEOF (input));
- size_t i;
my_u32_possible_linebreaks (input, SIZEOF (input), "UTF-8", p);
- for (i = 0; i < 4; i++)
+ for (size_t i = 0; i < 4; i++)
{
ASSERT (p[i] == (i == 3 ? UC_BREAK_POSSIBLE : UC_BREAK_PROHIBITED));
}
'e', 'n', 'c', 'e', '.', '<', '/', 'P', '>'
};
char *p = (char *) malloc (SIZEOF (input));
- size_t i;
my_u32_possible_linebreaks (input, SIZEOF (input), "UTF-8", p);
- for (i = 0; i < 21; i++)
+ for (size_t i = 0; i < 21; i++)
{
ASSERT (p[i] == (i == 8 || i == 17 || i == 19 ? UC_BREAK_POSSIBLE :
UC_BREAK_PROHIBITED));
0x0300
};
char *p = (char *) malloc (SIZEOF (input));
- size_t i;
my_u32_possible_linebreaks (input, SIZEOF (input), "UTF-8", p);
- for (i = 0; i < 16; i++)
+ for (size_t i = 0; i < 16; i++)
{
ASSERT (p[i] == (i == 14 ? UC_BREAK_MANDATORY :
i == 6 || i == 9 || i == 11 ? UC_BREAK_POSSIBLE :
0x261D, 0x200D, 0x1F3FF, '\n',
};
char *p = (char *) malloc (SIZEOF (input));
- size_t i;
my_u32_possible_linebreaks (input, SIZEOF (input), "UTF-8", p);
- for (i = 0; i < 37; i++)
+ for (size_t i = 0; i < 37; i++)
{
ASSERT (p[i] == (i == 8 || i == 20
|| i == 24 || i == 29
static const uint32_t input[4] =
{ 0x1F1E9, 0x1F1EA, 0x1F1EB, 0x1F1F7 };
char *p = (char *) malloc (SIZEOF (input));
- size_t i;
my_u32_possible_linebreaks (input, SIZEOF (input), "UTF-8", p);
- for (i = 0; i < 4; i++)
+ for (size_t i = 0; i < 4; i++)
{
ASSERT (p[i] == (i == 2 ? UC_BREAK_POSSIBLE : UC_BREAK_PROHIBITED));
}
static const uint32_t input[10] = /* "ab-אב-αβ-ω" */
{ 'a', 'b', '-', 0x05D0, 0x05D1, '-', 0x03B1, 0x03B2, '-', 0x03C9 };
char *p = (char *) malloc (SIZEOF (input));
- size_t i;
my_u32_possible_linebreaks (input, SIZEOF (input), "UTF-8", p);
- for (i = 0; i < 10; i++)
+ for (size_t i = 0; i < 10; i++)
{
ASSERT (p[i] == (i == 3 || i == 9 ? UC_BREAK_POSSIBLE :
UC_BREAK_PROHIBITED));
'G', 0x300C, 0x30E6, 0x30CB, 0x30B3, 0x30FC, 0x30C9, 0x300D
};
char *p = (char *) malloc (SIZEOF (input));
- size_t i;
my_u32_possible_linebreaks (input, SIZEOF (input), "UTF-8", p);
- for (i = 0; i < 17; i++)
+ for (size_t i = 0; i < 17; i++)
{
ASSERT (p[i] == (i == 1 || i == 2 || i == 3 || i == 4 || i == 5
|| i == 6 || i == 7 || i == 8 || i == 9
{
static const uint32_t input[2] = { 0x1FFFC, 0x1F3FF };
char *p = (char *) malloc (SIZEOF (input));
- size_t i;
my_u32_possible_linebreaks (input, SIZEOF (input), "UTF-8", p);
- for (i = 0; i < 2; i++)
+ for (size_t i = 0; i < 2; i++)
{
ASSERT (p[i] == UC_BREAK_PROHIBITED);
}
{
char *p = (char *) malloc (SIZEOF (input));
- size_t i;
my_u32_width_linebreaks (input, SIZEOF (input), 25, 0, 0, NULL, "GB18030", p);
- for (i = 0; i < 61; i++)
+ for (size_t i = 0; i < 61; i++)
{
ASSERT (p[i] == (i == 60 ? UC_BREAK_MANDATORY :
i == 25 || i == 45 ? UC_BREAK_POSSIBLE :
{
char *p = (char *) malloc (SIZEOF (input));
- size_t i;
my_u32_width_linebreaks (input, SIZEOF (input), 25, 0, 0, NULL, "GB2312", p);
- for (i = 0; i < 61; i++)
+ for (size_t i = 0; i < 61; i++)
{
ASSERT (p[i] == (i == 60 ? UC_BREAK_MANDATORY :
i == 11 || i == 25 || i == 45 ? UC_BREAK_POSSIBLE :
{
char *p = (char *) malloc (SIZEOF (input));
- size_t i;
my_u8_possible_linebreaks (input, SIZEOF (input), "GB18030", p);
- for (i = 0; i < 91; i++)
+ for (size_t i = 0; i < 91; i++)
{
ASSERT (p[i] == (i == 90 ? UC_BREAK_MANDATORY :
i == 7
{
char *p = (char *) malloc (SIZEOF (input));
- size_t i;
my_u8_possible_linebreaks (input, SIZEOF (input), "GB2312", p);
- for (i = 0; i < 91; i++)
+ for (size_t i = 0; i < 91; i++)
{
ASSERT (p[i] == (i == 90 ? UC_BREAK_MANDATORY :
i == 7
{
static const uint8_t input[8] _GL_ATTRIBUTE_NONSTRING = "a\nb\rc\r\nd";
char *p = (char *) malloc (SIZEOF (input));
- size_t i;
my_u8_possible_linebreaks (input, SIZEOF (input), "UTF-8", p);
- for (i = 0; i < 8; i++)
+ for (size_t i = 0; i < 8; i++)
{
ASSERT (p[i] == (i == 1 || i == 3 || i == 6 ? UC_BREAK_MANDATORY :
i == 5 ? (version < 2 ? UC_BREAK_MANDATORY : UC_BREAK_CR_BEFORE_LF) :
{
static const uint8_t input[6] _GL_ATTRIBUTE_NONSTRING = "x\342\200\213 y";
char *p = (char *) malloc (SIZEOF (input));
- size_t i;
my_u8_possible_linebreaks (input, SIZEOF (input), "UTF-8", p);
- for (i = 0; i < 6; i++)
+ for (size_t i = 0; i < 6; i++)
{
ASSERT (p[i] == (i == 5 ? UC_BREAK_POSSIBLE : UC_BREAK_PROHIBITED));
}
{
static const uint8_t input[21] _GL_ATTRIBUTE_NONSTRING = "<P>Some sentence.</P>";
char *p = (char *) malloc (SIZEOF (input));
- size_t i;
my_u8_possible_linebreaks (input, SIZEOF (input), "UTF-8", p);
- for (i = 0; i < 21; i++)
+ for (size_t i = 0; i < 21; i++)
{
ASSERT (p[i] == (i == 8 || i == 17 || i == 19 ? UC_BREAK_POSSIBLE :
UC_BREAK_PROHIBITED));
"a\314\200\314\201e\314\200 \314\201o \314\200 o\302\240\314\200\n"
"\314\200";
char *p = (char *) malloc (SIZEOF (input));
- size_t i;
my_u8_possible_linebreaks (input, SIZEOF (input), "UTF-8", p);
- for (i = 0; i < 24; i++)
+ for (size_t i = 0; i < 24; i++)
{
ASSERT (p[i] == (i == 21 ? UC_BREAK_MANDATORY :
i == 9 || i == 13 || i == 16 ? UC_BREAK_POSSIBLE :
"\342\230\235\360\237\217\277\n" /* "☝🏿" */
"\342\230\235\342\200\215\360\237\217\277\n";
char *p = (char *) malloc (SIZEOF (input));
- size_t i;
my_u8_possible_linebreaks (input, SIZEOF (input), "UTF-8", p);
- for (i = 0; i < 101; i++)
+ for (size_t i = 0; i < 101; i++)
{
ASSERT (p[i] == (i == 24 || i == 58
|| i == 68 || i == 81
static const uint8_t input[16] _GL_ATTRIBUTE_NONSTRING =
"\360\237\207\251\360\237\207\252\360\237\207\253\360\237\207\267";
char *p = (char *) malloc (SIZEOF (input));
- size_t i;
my_u8_possible_linebreaks (input, SIZEOF (input), "UTF-8", p);
- for (i = 0; i < 16; i++)
+ for (size_t i = 0; i < 16; i++)
{
ASSERT (p[i] == (i == 8 ? UC_BREAK_POSSIBLE : UC_BREAK_PROHIBITED));
}
static const uint8_t input[15] _GL_ATTRIBUTE_NONSTRING = /* "ab-אב-αβ-ω" */
"ab-\327\220\327\221-\316\261\316\262-\317\211";
char *p = (char *) malloc (SIZEOF (input));
- size_t i;
my_u8_possible_linebreaks (input, SIZEOF (input), "UTF-8", p);
- for (i = 0; i < 15; i++)
+ for (size_t i = 0; i < 15; i++)
{
ASSERT (p[i] == (i == 3 || i == 13 ? UC_BREAK_POSSIBLE :
UC_BREAK_PROHIBITED));
"\345\255\227\346\213\241\345\274\265G\343\200\214\343\203\246"
"\343\203\213\343\202\263\343\203\274\343\203\211\343\200\215";
char *p = (char *) malloc (SIZEOF (input));
- size_t i;
my_u8_possible_linebreaks (input, SIZEOF (input), "UTF-8", p);
- for (i = 0; i < 49; i++)
+ for (size_t i = 0; i < 49; i++)
{
ASSERT (p[i] == (i == 3 || i == 6 || i == 9 || i == 12 || i == 15
|| i == 18 || i == 21 || i == 24 || i == 27
static const uint8_t input[8] _GL_ATTRIBUTE_NONSTRING =
"\360\237\277\274\360\237\217\277";
char *p = (char *) malloc (SIZEOF (input));
- size_t i;
my_u8_possible_linebreaks (input, SIZEOF (input), "UTF-8", p);
- for (i = 0; i < 8; i++)
+ for (size_t i = 0; i < 8; i++)
{
ASSERT (p[i] == UC_BREAK_PROHIBITED);
}
{
char *p = (char *) malloc (SIZEOF (input));
- size_t i;
my_u8_width_linebreaks (input, SIZEOF (input), 25, 0, 0, NULL, "GB18030", p);
- for (i = 0; i < 91; i++)
+ for (size_t i = 0; i < 91; i++)
{
ASSERT (p[i] == (i == 90 ? UC_BREAK_MANDATORY :
i == 39 || i == 61 ? UC_BREAK_POSSIBLE :
{
char *p = (char *) malloc (SIZEOF (input));
- size_t i;
my_u8_width_linebreaks (input, SIZEOF (input), 25, 0, 0, NULL, "GB2312", p);
- for (i = 0; i < 91; i++)
+ for (size_t i = 0; i < 91; i++)
{
ASSERT (p[i] == (i == 90 ? UC_BREAK_MANDATORY :
i == 13 || i == 39 || i == 61 ? UC_BREAK_POSSIBLE :
u32_possible_linebreaks (input, i - 1, "UTF-8", breaks);
int matches = 1;
- {
- int j;
- for (j = 0; j < i - 1; j++)
- {
- /* The character U+FFFC has line break property CB, which according
- to rule (LB1) is resolved "into other line breaking classes
- depending on criteria outside the scope of this algorithm".
- Thus it makes no sense to check the breaks[] entry before or
- after such a character. */
- if (!(input[j] == 0xFFFC
- || (j > 0 && input[j - 1] == 0xFFFC)
- /* Also consider intervening characters with property LBP_CM
- or LBP_ZWJ, per (LB9). */
- || (j > 1 && (input[j - 1] == 0x0308 || input[j - 1] == 0x200D)
- && input[j - 2] == 0xFFFC)))
- /* A regional indicator with a combining character is nonsense,
- because regional indicators are supposed to come in pairs. */
- if (!(j >= 2 && (input[0] >= 0x1F1E6 && input[0] <= 0x1F1FF)
- && input[1] == 0x0308))
- /* It is nonsense to treat U+1F8FF differently than U+1F02C.
- Both are unassigned Extended_Pictographic characters and
- should therefore be treated like LBP_EB (or LBP_ID, if you
- want), not like LBP_AL. See rule (LB30b). */
- if (!(input[j] == 0x1F8FF
- || (j > 0 && input[j - 1] == 0x1F8FF)
- /* Also consider intervening characters with property LBP_CM
- or LBP_ZWJ, per (LB9). */
- || (j > 1 && (input[j - 1] == 0x0308 || input[j - 1] == 0x200D)
- && input[j - 2] == 0x1F8FF)))
- /* There is a disagreement regarding whether to allow a line break
- after a U+0020 SPACE character at the start of the text.
- We consider that the start of the text is equivalent to the
- state after a newline was seen; hence the loop starts with
- property LBP_BK. By the rules (LB4,LB5,LB6) an extra line
- break after a mandatory line break is undesired, even with
- intervening spaces (because these rules come before (LB18)).
- Whereas the LineBreakTest.txt file allows a line break after
- the space.
- Similarly when the first two characters at the start of the
- text have property LBP_CM and LBP_ZWJ, respectively. (LB9). */
- if (!(((j == 1 || (j > 1 && ((input[j - 2] >= 0x000A && input[j - 2] <= 0x000D) || input[j - 2] == 0x0085)))
- && input[j - 1] == 0x0020)
- || ((j == 2 || (j > 2 && ((input[j - 3] >= 0x000A && input[j - 3] <= 0x000D) || input[j - 3] == 0x0085)))
- && ((input[j - 2] == 0x0020 && input[j - 1] == 0x0020)
- || (input[j - 2] == 0x0308 && input[j - 1] == 0x200D)
- || (input[j - 2] == 0x200D && input[j - 1] == 0x0308)))))
- matches &= (!(breaks[j] == UC_BREAK_PROHIBITED
- || breaks[j] == UC_BREAK_MANDATORY
- || breaks[j] == UC_BREAK_CR_BEFORE_LF)
- || (j > 0 && breaks[j - 1] == UC_BREAK_MANDATORY))
- == breaks_expected[j];
- }
- }
+ for (int j = 0; j < i - 1; j++)
+ {
+ /* The character U+FFFC has line break property CB, which according
+ to rule (LB1) is resolved "into other line breaking classes
+ depending on criteria outside the scope of this algorithm".
+ Thus it makes no sense to check the breaks[] entry before or
+ after such a character. */
+ if (!(input[j] == 0xFFFC
+ || (j > 0 && input[j - 1] == 0xFFFC)
+ /* Also consider intervening characters with property LBP_CM
+ or LBP_ZWJ, per (LB9). */
+ || (j > 1 && (input[j - 1] == 0x0308 || input[j - 1] == 0x200D)
+ && input[j - 2] == 0xFFFC)))
+ /* A regional indicator with a combining character is nonsense,
+ because regional indicators are supposed to come in pairs. */
+ if (!(j >= 2 && (input[0] >= 0x1F1E6 && input[0] <= 0x1F1FF)
+ && input[1] == 0x0308))
+ /* It is nonsense to treat U+1F8FF differently than U+1F02C.
+ Both are unassigned Extended_Pictographic characters and
+ should therefore be treated like LBP_EB (or LBP_ID, if you
+ want), not like LBP_AL. See rule (LB30b). */
+ if (!(input[j] == 0x1F8FF
+ || (j > 0 && input[j - 1] == 0x1F8FF)
+ /* Also consider intervening characters with property LBP_CM
+ or LBP_ZWJ, per (LB9). */
+ || (j > 1 && (input[j - 1] == 0x0308 || input[j - 1] == 0x200D)
+ && input[j - 2] == 0x1F8FF)))
+ /* There is a disagreement regarding whether to allow a line break
+ after a U+0020 SPACE character at the start of the text.
+ We consider that the start of the text is equivalent to the
+ state after a newline was seen; hence the loop starts with
+ property LBP_BK. By the rules (LB4,LB5,LB6) an extra line
+ break after a mandatory line break is undesired, even with
+ intervening spaces (because these rules come before (LB18)).
+ Whereas the LineBreakTest.txt file allows a line break after
+ the space.
+ Similarly when the first two characters at the start of the
+ text have property LBP_CM and LBP_ZWJ, respectively. (LB9). */
+ if (!(((j == 1 || (j > 1 && ((input[j - 2] >= 0x000A && input[j - 2] <= 0x000D) || input[j - 2] == 0x0085)))
+ && input[j - 1] == 0x0020)
+ || ((j == 2 || (j > 2 && ((input[j - 3] >= 0x000A && input[j - 3] <= 0x000D) || input[j - 3] == 0x0085)))
+ && ((input[j - 2] == 0x0020 && input[j - 1] == 0x0020)
+ || (input[j - 2] == 0x0308 && input[j - 1] == 0x200D)
+ || (input[j - 2] == 0x200D && input[j - 1] == 0x0308)))))
+ matches &= (!(breaks[j] == UC_BREAK_PROHIBITED
+ || breaks[j] == UC_BREAK_MANDATORY
+ || breaks[j] == UC_BREAK_CR_BEFORE_LF)
+ || (j > 0 && breaks[j - 1] == UC_BREAK_MANDATORY))
+ == breaks_expected[j];
+ }
if (!matches)
{
- int j;
-
fprintf (stderr, "%s:%d: expected: ", filename, lineno);
- for (j = 0; j < i - 1; j++)
+ for (int j = 0; j < i - 1; j++)
fprintf (stderr, "%s U+%04X ",
breaks_expected[j] == 1 ? "\303\267" : "\303\227",
input[j]);
fprintf (stderr, "\n");
fprintf (stderr, "%s:%d: actual: ", filename, lineno);
- for (j = 0; j < i - 1; j++)
+ for (int j = 0; j < i - 1; j++)
fprintf (stderr, "%s U+%04X ",
(!(breaks[j] == UC_BREAK_PROHIBITED
|| breaks[j] == UC_BREAK_MANDATORY
/* "Grüß Gott. x=(-b±sqrt(b²-4ac))/(2a)" */
"Gr\374\337 Gott. x=(-b\261sqrt(b\262-4ac))/(2a)\n";
char *p = (char *) malloc (SIZEOF (input));
- size_t i;
my_ulc_possible_linebreaks (input, SIZEOF (input), "ISO-8859-1", p);
- for (i = 0; i < 36; i++)
+ for (size_t i = 0; i < 36; i++)
{
ASSERT (p[i] == (i == 35 ? UC_BREAK_MANDATORY :
i == 5 || i == 11 || i == 15
static const char input[21] _GL_ATTRIBUTE_NONSTRING =
"<P>Some sentence.</P>";
char *p = (char *) malloc (SIZEOF (input));
- size_t i;
my_ulc_possible_linebreaks (input, SIZEOF (input), "UTF-8", p);
- for (i = 0; i < 21; i++)
+ for (size_t i = 0; i < 21; i++)
{
ASSERT (p[i] == (i == 8 || i == 17 || i == 19 ? UC_BREAK_POSSIBLE :
UC_BREAK_PROHIBITED));
/* "Grüß Gott. x=(-b±sqrt(b²-4ac))/(2a)" */
"Gr\374\337 Gott. x=(-b\261sqrt(b\262-4ac))/(2a)\n";
char *p = (char *) malloc (SIZEOF (input));
- size_t i;
my_ulc_width_linebreaks (input, SIZEOF (input), 12, 0, 0, NULL, "ISO-8859-1", p);
- for (i = 0; i < 36; i++)
+ for (size_t i = 0; i < 36; i++)
{
ASSERT (p[i] == (i == 35 ? UC_BREAK_MANDATORY :
i == 11 || i == 15 || i == 31 ? UC_BREAK_POSSIBLE :
static int
name_has_alias (unsigned int uc)
{
- int i;
- for (i = 0; i < ALIASLEN; i++)
+ for (int i = 0; i < ALIASLEN; i++)
if (unicode_aliases[i].uc == uc)
return 1;
return 0;
test_name_lookup ()
{
int error = 0;
- unsigned int i;
char buf[UNINAME_MAX];
- for (i = 0; i < 0x11000; i++)
+ for (unsigned int i = 0; i < 0x11000; i++)
{
char *result = unicode_character_name (i, buf);
}
}
- for (i = 0x110000; i < 0x1000000; i++)
+ for (unsigned int i = 0x110000; i < 0x1000000; i++)
{
char *result = unicode_character_name (i, buf);
test_inverse_lookup ()
{
int error = 0;
- unsigned int i;
/* First, verify all valid character names are recognized. */
- for (i = 0; i < 0x110000; i++)
+ for (unsigned int i = 0; i < 0x110000; i++)
if (unicode_names[i] != NULL)
{
unsigned int result = unicode_name_character (unicode_names[i]);
/* Second, generate random but likely names and verify they are not
recognized unless really valid. */
- for (i = 0; i < 10000; i++)
+ for (unsigned int i = 0; i < 10000; i++)
{
unsigned int i1, i2;
const char *s1;
const char *s2;
- unsigned int l1, l2, j1, j2;
+ unsigned int l1, l2;
char buf[2*UNINAME_MAX];
unsigned int result;
l2 = strlen (s2);
/* Concatenate a starting piece of s1 with an ending piece of s2. */
- for (j1 = 1; j1 <= l1; j1++)
+ for (unsigned int j1 = 1; j1 <= l1; j1++)
if (j1 == l1 || s1[j1] == ' ')
- for (j2 = 0; j2 < l2; j2++)
+ for (unsigned int j2 = 0; j2 < l2; j2++)
if (j2 == 0 || s2[j2-1] == ' ')
{
memcpy (buf, s1, j1);
test_alias_lookup ()
{
int error = 0;
- unsigned int i;
char buf[UNINAME_MAX];
/* Verify all valid character names are recognized. */
- for (i = 0; i < ALIASLEN; i++)
+ for (unsigned int i = 0; i < ALIASLEN; i++)
if (unicode_aliases[i].uc != UNINAME_INVALID
/* Skip if the character has no canonical name (e.g. control
characters). */
if (i < argc)
{
- int j;
- for (j = 0; j < ALIASLEN; j++)
+ for (int j = 0; j < ALIASLEN; j++)
unicode_aliases[j].uc = UNINAME_INVALID;
i++;
#endif
/* Check that the sorting is not O(n²) but O(n log n). */
- {
- int pass;
- for (pass = 0; pass < 3; pass++)
- {
- size_t repeat = 1;
- size_t m = 100000;
- uint16_t *input = (uint16_t *) malloc (2 * m * sizeof (uint16_t));
- if (input != NULL)
- {
- uint16_t *expected = input + m;
- size_t m1 = m / 2;
- size_t m2 = (m - 1) / 2;
- /* NB: m1 + m2 == m - 1. */
- uint16_t *p;
- size_t i;
-
- input[0] = 0x0041;
- p = input + 1;
- switch (pass)
- {
- case 0:
- for (i = 0; i < m1; i++)
+ for (int pass = 0; pass < 3; pass++)
+ {
+ size_t repeat = 1;
+ size_t m = 100000;
+ uint16_t *input = (uint16_t *) malloc (2 * m * sizeof (uint16_t));
+ if (input != NULL)
+ {
+ uint16_t *expected = input + m;
+ size_t m1 = m / 2;
+ size_t m2 = (m - 1) / 2;
+ /* NB: m1 + m2 == m - 1. */
+ uint16_t *p;
+
+ input[0] = 0x0041;
+ p = input + 1;
+ switch (pass)
+ {
+ case 0:
+ for (size_t i = 0; i < m1; i++)
+ *p++ = 0x0319;
+ for (size_t i = 0; i < m2; i++)
+ *p++ = 0x0300;
+ break;
+
+ case 1:
+ for (size_t i = 0; i < m2; i++)
+ *p++ = 0x0300;
+ for (size_t i = 0; i < m1; i++)
+ *p++ = 0x0319;
+ break;
+
+ case 2:
+ for (size_t i = 0; i < m2; i++)
+ {
*p++ = 0x0319;
- for (i = 0; i < m2; i++)
- *p++ = 0x0300;
- break;
-
- case 1:
- for (i = 0; i < m2; i++)
*p++ = 0x0300;
- for (i = 0; i < m1; i++)
- *p++ = 0x0319;
- break;
-
- case 2:
- for (i = 0; i < m2; i++)
- {
- *p++ = 0x0319;
- *p++ = 0x0300;
- }
- for (; i < m1; i++)
- *p++ = 0x0319;
- break;
-
- default:
- abort ();
- }
-
- expected[0] = 0x00C0;
- p = expected + 1;
- for (i = 0; i < m1; i++)
- *p++ = 0x0319;
- for (i = 0; i < m2 - 1; i++)
- *p++ = 0x0300;
-
- for (; repeat > 0; repeat--)
- {
- ASSERT (check (input, m, expected, m - 1) == 0);
- ASSERT (check (expected, m - 1, expected, m - 1) == 0);
- }
-
- free (input);
- }
- }
- }
+ }
+ for (size_t i = m2; i < m1; i++)
+ *p++ = 0x0319;
+ break;
+
+ default:
+ abort ();
+ }
+
+ expected[0] = 0x00C0;
+ p = expected + 1;
+ for (size_t i = 0; i < m1; i++)
+ *p++ = 0x0319;
+ for (size_t i = 0; i < m2 - 1; i++)
+ *p++ = 0x0300;
+
+ for (; repeat > 0; repeat--)
+ {
+ ASSERT (check (input, m, expected, m - 1) == 0);
+ ASSERT (check (expected, m - 1, expected, m - 1) == 0);
+ }
+
+ free (input);
+ }
+ }
}
#else
#endif
/* Check that the sorting is not O(n²) but O(n log n). */
- {
- int pass;
- for (pass = 0; pass < 3; pass++)
- {
- size_t repeat = 1;
- size_t m = 100000;
- uint16_t *input = (uint16_t *) malloc (2 * m * sizeof (uint16_t));
- if (input != NULL)
- {
- uint16_t *expected = input + m;
- size_t m1 = m / 2;
- size_t m2 = (m - 1) / 2;
- /* NB: m1 + m2 == m - 1. */
- uint16_t *p;
- size_t i;
-
- input[0] = 0x0041;
- p = input + 1;
- switch (pass)
- {
- case 0:
- for (i = 0; i < m1; i++)
+ for (int pass = 0; pass < 3; pass++)
+ {
+ size_t repeat = 1;
+ size_t m = 100000;
+ uint16_t *input = (uint16_t *) malloc (2 * m * sizeof (uint16_t));
+ if (input != NULL)
+ {
+ uint16_t *expected = input + m;
+ size_t m1 = m / 2;
+ size_t m2 = (m - 1) / 2;
+ /* NB: m1 + m2 == m - 1. */
+ uint16_t *p;
+
+ input[0] = 0x0041;
+ p = input + 1;
+ switch (pass)
+ {
+ case 0:
+ for (size_t i = 0; i < m1; i++)
+ *p++ = 0x0319;
+ for (size_t i = 0; i < m2; i++)
+ *p++ = 0x0300;
+ break;
+
+ case 1:
+ for (size_t i = 0; i < m2; i++)
+ *p++ = 0x0300;
+ for (size_t i = 0; i < m1; i++)
+ *p++ = 0x0319;
+ break;
+
+ case 2:
+ for (size_t i = 0; i < m2; i++)
+ {
*p++ = 0x0319;
- for (i = 0; i < m2; i++)
- *p++ = 0x0300;
- break;
-
- case 1:
- for (i = 0; i < m2; i++)
*p++ = 0x0300;
- for (i = 0; i < m1; i++)
- *p++ = 0x0319;
- break;
-
- case 2:
- for (i = 0; i < m2; i++)
- {
- *p++ = 0x0319;
- *p++ = 0x0300;
- }
- for (; i < m1; i++)
- *p++ = 0x0319;
- break;
-
- default:
- abort ();
- }
-
- expected[0] = 0x0041;
- p = expected + 1;
- for (i = 0; i < m1; i++)
- *p++ = 0x0319;
- for (i = 0; i < m2; i++)
- *p++ = 0x0300;
-
- for (; repeat > 0; repeat--)
- ASSERT (check (input, m, expected, m) == 0);
-
- free (input);
- }
- }
- }
+ }
+ for (size_t i = m2; i < m1; i++)
+ *p++ = 0x0319;
+ break;
+
+ default:
+ abort ();
+ }
+
+ expected[0] = 0x0041;
+ p = expected + 1;
+ for (size_t i = 0; i < m1; i++)
+ *p++ = 0x0319;
+ for (size_t i = 0; i < m2; i++)
+ *p++ = 0x0300;
+
+ for (; repeat > 0; repeat--)
+ ASSERT (check (input, m, expected, m) == 0);
+
+ free (input);
+ }
+ }
}
#else
#endif
/* Check that the sorting is not O(n²) but O(n log n). */
- {
- int pass;
- for (pass = 0; pass < 3; pass++)
- {
- size_t repeat = 1;
- size_t m = 100000;
- uint16_t *input = (uint16_t *) malloc (2 * m * sizeof (uint16_t));
- if (input != NULL)
- {
- uint16_t *expected = input + m;
- size_t m1 = m / 2;
- size_t m2 = (m - 1) / 2;
- /* NB: m1 + m2 == m - 1. */
- uint16_t *p;
- size_t i;
-
- input[0] = 0x0041;
- p = input + 1;
- switch (pass)
- {
- case 0:
- for (i = 0; i < m1; i++)
+ for (int pass = 0; pass < 3; pass++)
+ {
+ size_t repeat = 1;
+ size_t m = 100000;
+ uint16_t *input = (uint16_t *) malloc (2 * m * sizeof (uint16_t));
+ if (input != NULL)
+ {
+ uint16_t *expected = input + m;
+ size_t m1 = m / 2;
+ size_t m2 = (m - 1) / 2;
+ /* NB: m1 + m2 == m - 1. */
+ uint16_t *p;
+
+ input[0] = 0x0041;
+ p = input + 1;
+ switch (pass)
+ {
+ case 0:
+ for (size_t i = 0; i < m1; i++)
+ *p++ = 0x0319;
+ for (size_t i = 0; i < m2; i++)
+ *p++ = 0x0300;
+ break;
+
+ case 1:
+ for (size_t i = 0; i < m2; i++)
+ *p++ = 0x0300;
+ for (size_t i = 0; i < m1; i++)
+ *p++ = 0x0319;
+ break;
+
+ case 2:
+ for (size_t i = 0; i < m2; i++)
+ {
*p++ = 0x0319;
- for (i = 0; i < m2; i++)
- *p++ = 0x0300;
- break;
-
- case 1:
- for (i = 0; i < m2; i++)
*p++ = 0x0300;
- for (i = 0; i < m1; i++)
- *p++ = 0x0319;
- break;
-
- case 2:
- for (i = 0; i < m2; i++)
- {
- *p++ = 0x0319;
- *p++ = 0x0300;
- }
- for (; i < m1; i++)
- *p++ = 0x0319;
- break;
-
- default:
- abort ();
- }
-
- expected[0] = 0x00C0;
- p = expected + 1;
- for (i = 0; i < m1; i++)
- *p++ = 0x0319;
- for (i = 0; i < m2 - 1; i++)
- *p++ = 0x0300;
-
- for (; repeat > 0; repeat--)
- {
- ASSERT (check (input, m, expected, m - 1) == 0);
- ASSERT (check (expected, m - 1, expected, m - 1) == 0);
- }
-
- free (input);
- }
- }
- }
+ }
+ for (size_t i = m2; i < m1; i++)
+ *p++ = 0x0319;
+ break;
+
+ default:
+ abort ();
+ }
+
+ expected[0] = 0x00C0;
+ p = expected + 1;
+ for (size_t i = 0; i < m1; i++)
+ *p++ = 0x0319;
+ for (size_t i = 0; i < m2 - 1; i++)
+ *p++ = 0x0300;
+
+ for (; repeat > 0; repeat--)
+ {
+ ASSERT (check (input, m, expected, m - 1) == 0);
+ ASSERT (check (expected, m - 1, expected, m - 1) == 0);
+ }
+
+ free (input);
+ }
+ }
}
#else
#endif
/* Check that the sorting is not O(n²) but O(n log n). */
- {
- int pass;
- for (pass = 0; pass < 3; pass++)
- {
- size_t repeat = 1;
- size_t m = 100000;
- uint16_t *input = (uint16_t *) malloc (2 * m * sizeof (uint16_t));
- if (input != NULL)
- {
- uint16_t *expected = input + m;
- size_t m1 = m / 2;
- size_t m2 = (m - 1) / 2;
- /* NB: m1 + m2 == m - 1. */
- uint16_t *p;
- size_t i;
-
- input[0] = 0x0041;
- p = input + 1;
- switch (pass)
- {
- case 0:
- for (i = 0; i < m1; i++)
+ for (int pass = 0; pass < 3; pass++)
+ {
+ size_t repeat = 1;
+ size_t m = 100000;
+ uint16_t *input = (uint16_t *) malloc (2 * m * sizeof (uint16_t));
+ if (input != NULL)
+ {
+ uint16_t *expected = input + m;
+ size_t m1 = m / 2;
+ size_t m2 = (m - 1) / 2;
+ /* NB: m1 + m2 == m - 1. */
+ uint16_t *p;
+
+ input[0] = 0x0041;
+ p = input + 1;
+ switch (pass)
+ {
+ case 0:
+ for (size_t i = 0; i < m1; i++)
+ *p++ = 0x0319;
+ for (size_t i = 0; i < m2; i++)
+ *p++ = 0x0300;
+ break;
+
+ case 1:
+ for (size_t i = 0; i < m2; i++)
+ *p++ = 0x0300;
+ for (size_t i = 0; i < m1; i++)
+ *p++ = 0x0319;
+ break;
+
+ case 2:
+ for (size_t i = 0; i < m2; i++)
+ {
*p++ = 0x0319;
- for (i = 0; i < m2; i++)
- *p++ = 0x0300;
- break;
-
- case 1:
- for (i = 0; i < m2; i++)
*p++ = 0x0300;
- for (i = 0; i < m1; i++)
- *p++ = 0x0319;
- break;
-
- case 2:
- for (i = 0; i < m2; i++)
- {
- *p++ = 0x0319;
- *p++ = 0x0300;
- }
- for (; i < m1; i++)
- *p++ = 0x0319;
- break;
-
- default:
- abort ();
- }
-
- expected[0] = 0x0041;
- p = expected + 1;
- for (i = 0; i < m1; i++)
- *p++ = 0x0319;
- for (i = 0; i < m2; i++)
- *p++ = 0x0300;
-
- for (; repeat > 0; repeat--)
- ASSERT (check (input, m, expected, m) == 0);
-
- free (input);
- }
- }
- }
+ }
+ for (size_t i = m2; i < m1; i++)
+ *p++ = 0x0319;
+ break;
+
+ default:
+ abort ();
+ }
+
+ expected[0] = 0x0041;
+ p = expected + 1;
+ for (size_t i = 0; i < m1; i++)
+ *p++ = 0x0319;
+ for (size_t i = 0; i < m2; i++)
+ *p++ = 0x0300;
+
+ for (; repeat > 0; repeat--)
+ ASSERT (check (input, m, expected, m) == 0);
+
+ free (input);
+ }
+ }
}
#else
#endif
/* Check that the sorting is not O(n²) but O(n log n). */
- {
- int pass;
- for (pass = 0; pass < 3; pass++)
- {
- size_t repeat = 1;
- size_t m = 100000;
- uint32_t *input = (uint32_t *) malloc (2 * m * sizeof (uint32_t));
- if (input != NULL)
- {
- uint32_t *expected = input + m;
- size_t m1 = m / 2;
- size_t m2 = (m - 1) / 2;
- /* NB: m1 + m2 == m - 1. */
- uint32_t *p;
- size_t i;
-
- input[0] = 0x0041;
- p = input + 1;
- switch (pass)
- {
- case 0:
- for (i = 0; i < m1; i++)
+ for (int pass = 0; pass < 3; pass++)
+ {
+ size_t repeat = 1;
+ size_t m = 100000;
+ uint32_t *input = (uint32_t *) malloc (2 * m * sizeof (uint32_t));
+ if (input != NULL)
+ {
+ uint32_t *expected = input + m;
+ size_t m1 = m / 2;
+ size_t m2 = (m - 1) / 2;
+ /* NB: m1 + m2 == m - 1. */
+ uint32_t *p;
+
+ input[0] = 0x0041;
+ p = input + 1;
+ switch (pass)
+ {
+ case 0:
+ for (size_t i = 0; i < m1; i++)
+ *p++ = 0x0319;
+ for (size_t i = 0; i < m2; i++)
+ *p++ = 0x0300;
+ break;
+
+ case 1:
+ for (size_t i = 0; i < m2; i++)
+ *p++ = 0x0300;
+ for (size_t i = 0; i < m1; i++)
+ *p++ = 0x0319;
+ break;
+
+ case 2:
+ for (size_t i = 0; i < m2; i++)
+ {
*p++ = 0x0319;
- for (i = 0; i < m2; i++)
- *p++ = 0x0300;
- break;
-
- case 1:
- for (i = 0; i < m2; i++)
*p++ = 0x0300;
- for (i = 0; i < m1; i++)
- *p++ = 0x0319;
- break;
-
- case 2:
- for (i = 0; i < m2; i++)
- {
- *p++ = 0x0319;
- *p++ = 0x0300;
- }
- for (; i < m1; i++)
- *p++ = 0x0319;
- break;
-
- default:
- abort ();
- }
-
- expected[0] = 0x00C0;
- p = expected + 1;
- for (i = 0; i < m1; i++)
- *p++ = 0x0319;
- for (i = 0; i < m2 - 1; i++)
- *p++ = 0x0300;
-
- for (; repeat > 0; repeat--)
- {
- ASSERT (check (input, m, expected, m - 1) == 0);
- ASSERT (check (expected, m - 1, expected, m - 1) == 0);
- }
-
- free (input);
- }
- }
- }
+ }
+ for (size_t i = m2; i < m1; i++)
+ *p++ = 0x0319;
+ break;
+
+ default:
+ abort ();
+ }
+
+ expected[0] = 0x00C0;
+ p = expected + 1;
+ for (size_t i = 0; i < m1; i++)
+ *p++ = 0x0319;
+ for (size_t i = 0; i < m2 - 1; i++)
+ *p++ = 0x0300;
+
+ for (; repeat > 0; repeat--)
+ {
+ ASSERT (check (input, m, expected, m - 1) == 0);
+ ASSERT (check (expected, m - 1, expected, m - 1) == 0);
+ }
+
+ free (input);
+ }
+ }
}
#else
#endif
/* Check that the sorting is not O(n²) but O(n log n). */
- {
- int pass;
- for (pass = 0; pass < 3; pass++)
- {
- size_t repeat = 1;
- size_t m = 100000;
- uint32_t *input = (uint32_t *) malloc (2 * m * sizeof (uint32_t));
- if (input != NULL)
- {
- uint32_t *expected = input + m;
- size_t m1 = m / 2;
- size_t m2 = (m - 1) / 2;
- /* NB: m1 + m2 == m - 1. */
- uint32_t *p;
- size_t i;
-
- input[0] = 0x0041;
- p = input + 1;
- switch (pass)
- {
- case 0:
- for (i = 0; i < m1; i++)
+ for (int pass = 0; pass < 3; pass++)
+ {
+ size_t repeat = 1;
+ size_t m = 100000;
+ uint32_t *input = (uint32_t *) malloc (2 * m * sizeof (uint32_t));
+ if (input != NULL)
+ {
+ uint32_t *expected = input + m;
+ size_t m1 = m / 2;
+ size_t m2 = (m - 1) / 2;
+ /* NB: m1 + m2 == m - 1. */
+ uint32_t *p;
+
+ input[0] = 0x0041;
+ p = input + 1;
+ switch (pass)
+ {
+ case 0:
+ for (size_t i = 0; i < m1; i++)
+ *p++ = 0x0319;
+ for (size_t i = 0; i < m2; i++)
+ *p++ = 0x0300;
+ break;
+
+ case 1:
+ for (size_t i = 0; i < m2; i++)
+ *p++ = 0x0300;
+ for (size_t i = 0; i < m1; i++)
+ *p++ = 0x0319;
+ break;
+
+ case 2:
+ for (size_t i = 0; i < m2; i++)
+ {
*p++ = 0x0319;
- for (i = 0; i < m2; i++)
- *p++ = 0x0300;
- break;
-
- case 1:
- for (i = 0; i < m2; i++)
*p++ = 0x0300;
- for (i = 0; i < m1; i++)
- *p++ = 0x0319;
- break;
-
- case 2:
- for (i = 0; i < m2; i++)
- {
- *p++ = 0x0319;
- *p++ = 0x0300;
- }
- for (; i < m1; i++)
- *p++ = 0x0319;
- break;
-
- default:
- abort ();
- }
-
- expected[0] = 0x0041;
- p = expected + 1;
- for (i = 0; i < m1; i++)
- *p++ = 0x0319;
- for (i = 0; i < m2; i++)
- *p++ = 0x0300;
-
- for (; repeat > 0; repeat--)
- ASSERT (check (input, m, expected, m) == 0);
-
- free (input);
- }
- }
- }
+ }
+ for (size_t i = m2; i < m1; i++)
+ *p++ = 0x0319;
+ break;
+
+ default:
+ abort ();
+ }
+
+ expected[0] = 0x0041;
+ p = expected + 1;
+ for (size_t i = 0; i < m1; i++)
+ *p++ = 0x0319;
+ for (size_t i = 0; i < m2; i++)
+ *p++ = 0x0300;
+
+ for (; repeat > 0; repeat--)
+ ASSERT (check (input, m, expected, m) == 0);
+
+ free (input);
+ }
+ }
}
#else
#endif
/* Check that the sorting is not O(n²) but O(n log n). */
- {
- int pass;
- for (pass = 0; pass < 3; pass++)
- {
- size_t repeat = 1;
- size_t m = 100000;
- uint32_t *input = (uint32_t *) malloc (2 * m * sizeof (uint32_t));
- if (input != NULL)
- {
- uint32_t *expected = input + m;
- size_t m1 = m / 2;
- size_t m2 = (m - 1) / 2;
- /* NB: m1 + m2 == m - 1. */
- uint32_t *p;
- size_t i;
-
- input[0] = 0x0041;
- p = input + 1;
- switch (pass)
- {
- case 0:
- for (i = 0; i < m1; i++)
+ for (int pass = 0; pass < 3; pass++)
+ {
+ size_t repeat = 1;
+ size_t m = 100000;
+ uint32_t *input = (uint32_t *) malloc (2 * m * sizeof (uint32_t));
+ if (input != NULL)
+ {
+ uint32_t *expected = input + m;
+ size_t m1 = m / 2;
+ size_t m2 = (m - 1) / 2;
+ /* NB: m1 + m2 == m - 1. */
+ uint32_t *p;
+
+ input[0] = 0x0041;
+ p = input + 1;
+ switch (pass)
+ {
+ case 0:
+ for (size_t i = 0; i < m1; i++)
+ *p++ = 0x0319;
+ for (size_t i = 0; i < m2; i++)
+ *p++ = 0x0300;
+ break;
+
+ case 1:
+ for (size_t i = 0; i < m2; i++)
+ *p++ = 0x0300;
+ for (size_t i = 0; i < m1; i++)
+ *p++ = 0x0319;
+ break;
+
+ case 2:
+ for (size_t i = 0; i < m2; i++)
+ {
*p++ = 0x0319;
- for (i = 0; i < m2; i++)
- *p++ = 0x0300;
- break;
-
- case 1:
- for (i = 0; i < m2; i++)
*p++ = 0x0300;
- for (i = 0; i < m1; i++)
- *p++ = 0x0319;
- break;
-
- case 2:
- for (i = 0; i < m2; i++)
- {
- *p++ = 0x0319;
- *p++ = 0x0300;
- }
- for (; i < m1; i++)
- *p++ = 0x0319;
- break;
-
- default:
- abort ();
- }
-
- expected[0] = 0x00C0;
- p = expected + 1;
- for (i = 0; i < m1; i++)
- *p++ = 0x0319;
- for (i = 0; i < m2 - 1; i++)
- *p++ = 0x0300;
-
- for (; repeat > 0; repeat--)
- {
- ASSERT (check (input, m, expected, m - 1) == 0);
- ASSERT (check (expected, m - 1, expected, m - 1) == 0);
- }
-
- free (input);
- }
- }
- }
+ }
+ for (size_t i = m2; i < m1; i++)
+ *p++ = 0x0319;
+ break;
+
+ default:
+ abort ();
+ }
+
+ expected[0] = 0x00C0;
+ p = expected + 1;
+ for (size_t i = 0; i < m1; i++)
+ *p++ = 0x0319;
+ for (size_t i = 0; i < m2 - 1; i++)
+ *p++ = 0x0300;
+
+ for (; repeat > 0; repeat--)
+ {
+ ASSERT (check (input, m, expected, m - 1) == 0);
+ ASSERT (check (expected, m - 1, expected, m - 1) == 0);
+ }
+
+ free (input);
+ }
+ }
}
#else
#endif
/* Check that the sorting is not O(n²) but O(n log n). */
- {
- int pass;
- for (pass = 0; pass < 3; pass++)
- {
- size_t repeat = 1;
- size_t m = 100000;
- uint32_t *input = (uint32_t *) malloc (2 * m * sizeof (uint32_t));
- if (input != NULL)
- {
- uint32_t *expected = input + m;
- size_t m1 = m / 2;
- size_t m2 = (m - 1) / 2;
- /* NB: m1 + m2 == m - 1. */
- uint32_t *p;
- size_t i;
-
- input[0] = 0x0041;
- p = input + 1;
- switch (pass)
- {
- case 0:
- for (i = 0; i < m1; i++)
+ for (int pass = 0; pass < 3; pass++)
+ {
+ size_t repeat = 1;
+ size_t m = 100000;
+ uint32_t *input = (uint32_t *) malloc (2 * m * sizeof (uint32_t));
+ if (input != NULL)
+ {
+ uint32_t *expected = input + m;
+ size_t m1 = m / 2;
+ size_t m2 = (m - 1) / 2;
+ /* NB: m1 + m2 == m - 1. */
+ uint32_t *p;
+
+ input[0] = 0x0041;
+ p = input + 1;
+ switch (pass)
+ {
+ case 0:
+ for (size_t i = 0; i < m1; i++)
+ *p++ = 0x0319;
+ for (size_t i = 0; i < m2; i++)
+ *p++ = 0x0300;
+ break;
+
+ case 1:
+ for (size_t i = 0; i < m2; i++)
+ *p++ = 0x0300;
+ for (size_t i = 0; i < m1; i++)
+ *p++ = 0x0319;
+ break;
+
+ case 2:
+ for (size_t i = 0; i < m2; i++)
+ {
*p++ = 0x0319;
- for (i = 0; i < m2; i++)
- *p++ = 0x0300;
- break;
-
- case 1:
- for (i = 0; i < m2; i++)
*p++ = 0x0300;
- for (i = 0; i < m1; i++)
- *p++ = 0x0319;
- break;
-
- case 2:
- for (i = 0; i < m2; i++)
- {
- *p++ = 0x0319;
- *p++ = 0x0300;
- }
- for (; i < m1; i++)
- *p++ = 0x0319;
- break;
-
- default:
- abort ();
- }
-
- expected[0] = 0x0041;
- p = expected + 1;
- for (i = 0; i < m1; i++)
- *p++ = 0x0319;
- for (i = 0; i < m2; i++)
- *p++ = 0x0300;
-
- for (; repeat > 0; repeat--)
- ASSERT (check (input, m, expected, m) == 0);
-
- free (input);
- }
- }
- }
+ }
+ for (size_t i = m2; i < m1; i++)
+ *p++ = 0x0319;
+ break;
+
+ default:
+ abort ();
+ }
+
+ expected[0] = 0x0041;
+ p = expected + 1;
+ for (size_t i = 0; i < m1; i++)
+ *p++ = 0x0319;
+ for (size_t i = 0; i < m2; i++)
+ *p++ = 0x0300;
+
+ for (; repeat > 0; repeat--)
+ ASSERT (check (input, m, expected, m) == 0);
+
+ free (input);
+ }
+ }
}
#else
{
FILE *stream;
unsigned int lineno;
- int part_index;
struct normalization_test_line *lines;
size_t lines_length;
size_t lines_allocated;
exit (1);
}
- for (part_index = 0; part_index < 6; part_index++)
+ for (int part_index = 0; part_index < 6; part_index++)
{
file->parts[part_index].lines = NULL;
file->parts[part_index].lines_length = 0;
lineno = 0;
- part_index = -1;
+ int part_index = -1;
lines = NULL;
lines_length = 0;
lines_allocated = 0;
char *ptr;
int c;
struct normalization_test_line line;
- size_t sequence_index;
lineno++;
}
ptr = buf;
line.lineno = lineno;
- for (sequence_index = 0; sequence_index < 5; sequence_index++)
+ for (size_t sequence_index = 0; sequence_index < 5; sequence_index++)
line.sequences[sequence_index] = NULL;
- for (sequence_index = 0; sequence_index < 5; sequence_index++)
+ for (size_t sequence_index = 0; sequence_index < 5; sequence_index++)
{
uint32_t *sequence = XNMALLOC (1, uint32_t);
size_t sequence_length = 0;
/* Collect all c1 values from the part 1 in an array. */
const struct normalization_test_part *p = &file->parts[1];
ucs4_t *c1_array = XNMALLOC (p->lines_length + 1, ucs4_t);
- size_t line_index;
- for (line_index = 0; line_index < p->lines_length; line_index++)
+ for (size_t line_index = 0; line_index < p->lines_length; line_index++)
{
const uint32_t *sequence = p->lines[line_index].sequences[0];
/* In part 1, every sequences[0] consists of a single character. */
const uint32_t *c4, size_t c4_length,
const uint32_t *c5, size_t c5_length))
{
- size_t part_index;
-
- for (part_index = 0; part_index < 6; part_index++)
+ for (size_t part_index = 0; part_index < 6; part_index++)
{
const struct normalization_test_part *p = &file->parts[part_index];
- size_t line_index;
- for (line_index = 0; line_index < p->lines_length; line_index++)
+ for (size_t line_index = 0; line_index < p->lines_length; line_index++)
{
const struct normalization_test_line *l = &p->lines[line_index];
NormalizationTest.txt file, the character maps to itself in each
of the four normalization forms. */
const ucs4_t *p = file->part1_c1_sorted;
- ucs4_t uc;
- for (uc = 0; uc < 0x110000; uc++)
+ for (ucs4_t uc = 0; uc < 0x110000; uc++)
{
if (uc >= 0xD800 && uc < 0xE000)
{
void
free_normalization_test_file (struct normalization_test_file *file)
{
- size_t part_index;
-
- for (part_index = 0; part_index < 6; part_index++)
+ for (size_t part_index = 0; part_index < 6; part_index++)
{
const struct normalization_test_part *p = &file->parts[part_index];
- size_t line_index;
- for (line_index = 0; line_index < p->lines_length; line_index++)
+ for (size_t line_index = 0; line_index < p->lines_length; line_index++)
{
const struct normalization_test_line *l = &p->lines[line_index];
- size_t sequence_index;
- for (sequence_index = 0; sequence_index < 5; sequence_index++)
+ for (size_t sequence_index = 0; sequence_index < 5; sequence_index++)
free (l->sequences[sequence_index]);
}
free (p->lines);
#endif
/* Check that the sorting is not O(n²) but O(n log n). */
- {
- int pass;
- for (pass = 0; pass < 3; pass++)
- {
- size_t repeat = 1;
- size_t m = 100000;
- uint8_t *input = (uint8_t *) malloc (2 * (2 * m - 1) * sizeof (uint8_t));
- if (input != NULL)
- {
- uint8_t *expected = input + (2 * m - 1);
- size_t m1 = m / 2;
- size_t m2 = (m - 1) / 2;
- /* NB: m1 + m2 == m - 1. */
- uint8_t *p;
- size_t i;
-
- input[0] = 0x41;
- p = input + 1;
- switch (pass)
- {
- case 0:
- for (i = 0; i < m1; i++)
- {
- *p++ = 0xCC;
- *p++ = 0x99;
- }
- for (i = 0; i < m2; i++)
- {
- *p++ = 0xCC;
- *p++ = 0x80;
- }
- break;
-
- case 1:
- for (i = 0; i < m2; i++)
- {
- *p++ = 0xCC;
- *p++ = 0x80;
- }
- for (i = 0; i < m1; i++)
- {
- *p++ = 0xCC;
- *p++ = 0x99;
- }
- break;
-
- case 2:
- for (i = 0; i < m2; i++)
- {
- *p++ = 0xCC;
- *p++ = 0x99;
- *p++ = 0xCC;
- *p++ = 0x80;
- }
- for (; i < m1; i++)
- {
- *p++ = 0xCC;
- *p++ = 0x99;
- }
- break;
-
- default:
- abort ();
- }
-
- expected[0] = 0xC3;
- expected[1] = 0x80;
- p = expected + 2;
- for (i = 0; i < m1; i++)
- {
- *p++ = 0xCC;
- *p++ = 0x99;
- }
- for (i = 0; i < m2 - 1; i++)
- {
- *p++ = 0xCC;
- *p++ = 0x80;
- }
-
- for (; repeat > 0; repeat--)
- {
- ASSERT (check (input, 2 * m - 1, expected, 2 * m - 2) == 0);
- ASSERT (check (expected, 2 * m - 2, expected, 2 * m - 2) == 0);
- }
-
- free (input);
- }
- }
- }
+ for (int pass = 0; pass < 3; pass++)
+ {
+ size_t repeat = 1;
+ size_t m = 100000;
+ uint8_t *input = (uint8_t *) malloc (2 * (2 * m - 1) * sizeof (uint8_t));
+ if (input != NULL)
+ {
+ uint8_t *expected = input + (2 * m - 1);
+ size_t m1 = m / 2;
+ size_t m2 = (m - 1) / 2;
+ /* NB: m1 + m2 == m - 1. */
+ uint8_t *p;
+
+ input[0] = 0x41;
+ p = input + 1;
+ switch (pass)
+ {
+ case 0:
+ for (size_t i = 0; i < m1; i++)
+ {
+ *p++ = 0xCC;
+ *p++ = 0x99;
+ }
+ for (size_t i = 0; i < m2; i++)
+ {
+ *p++ = 0xCC;
+ *p++ = 0x80;
+ }
+ break;
+
+ case 1:
+ for (size_t i = 0; i < m2; i++)
+ {
+ *p++ = 0xCC;
+ *p++ = 0x80;
+ }
+ for (size_t i = 0; i < m1; i++)
+ {
+ *p++ = 0xCC;
+ *p++ = 0x99;
+ }
+ break;
+
+ case 2:
+ for (size_t i = 0; i < m2; i++)
+ {
+ *p++ = 0xCC;
+ *p++ = 0x99;
+ *p++ = 0xCC;
+ *p++ = 0x80;
+ }
+ for (size_t i = m2; i < m1; i++)
+ {
+ *p++ = 0xCC;
+ *p++ = 0x99;
+ }
+ break;
+
+ default:
+ abort ();
+ }
+
+ expected[0] = 0xC3;
+ expected[1] = 0x80;
+ p = expected + 2;
+ for (size_t i = 0; i < m1; i++)
+ {
+ *p++ = 0xCC;
+ *p++ = 0x99;
+ }
+ for (size_t i = 0; i < m2 - 1; i++)
+ {
+ *p++ = 0xCC;
+ *p++ = 0x80;
+ }
+
+ for (; repeat > 0; repeat--)
+ {
+ ASSERT (check (input, 2 * m - 1, expected, 2 * m - 2) == 0);
+ ASSERT (check (expected, 2 * m - 2, expected, 2 * m - 2) == 0);
+ }
+
+ free (input);
+ }
+ }
}
#else
#endif
/* Check that the sorting is not O(n²) but O(n log n). */
- {
- int pass;
- for (pass = 0; pass < 3; pass++)
- {
- size_t repeat = 1;
- size_t m = 100000;
- uint8_t *input = (uint8_t *) malloc (2 * (2 * m - 1) * sizeof (uint8_t));
- if (input != NULL)
- {
- uint8_t *expected = input + (2 * m - 1);
- size_t m1 = m / 2;
- size_t m2 = (m - 1) / 2;
- /* NB: m1 + m2 == m - 1. */
- uint8_t *p;
- size_t i;
-
- input[0] = 0x41;
- p = input + 1;
- switch (pass)
- {
- case 0:
- for (i = 0; i < m1; i++)
- {
- *p++ = 0xCC;
- *p++ = 0x99;
- }
- for (i = 0; i < m2; i++)
- {
- *p++ = 0xCC;
- *p++ = 0x80;
- }
- break;
-
- case 1:
- for (i = 0; i < m2; i++)
- {
- *p++ = 0xCC;
- *p++ = 0x80;
- }
- for (i = 0; i < m1; i++)
- {
- *p++ = 0xCC;
- *p++ = 0x99;
- }
- break;
-
- case 2:
- for (i = 0; i < m2; i++)
- {
- *p++ = 0xCC;
- *p++ = 0x99;
- *p++ = 0xCC;
- *p++ = 0x80;
- }
- for (; i < m1; i++)
- {
- *p++ = 0xCC;
- *p++ = 0x99;
- }
- break;
-
- default:
- abort ();
- }
-
- expected[0] = 0x41;
- p = expected + 1;
- for (i = 0; i < m1; i++)
- {
- *p++ = 0xCC;
- *p++ = 0x99;
- }
- for (i = 0; i < m2; i++)
- {
- *p++ = 0xCC;
- *p++ = 0x80;
- }
-
- for (; repeat > 0; repeat--)
- ASSERT (check (input, 2 * m - 1, expected, 2 * m - 1) == 0);
-
- free (input);
- }
- }
- }
+ for (int pass = 0; pass < 3; pass++)
+ {
+ size_t repeat = 1;
+ size_t m = 100000;
+ uint8_t *input = (uint8_t *) malloc (2 * (2 * m - 1) * sizeof (uint8_t));
+ if (input != NULL)
+ {
+ uint8_t *expected = input + (2 * m - 1);
+ size_t m1 = m / 2;
+ size_t m2 = (m - 1) / 2;
+ /* NB: m1 + m2 == m - 1. */
+ uint8_t *p;
+
+ input[0] = 0x41;
+ p = input + 1;
+ switch (pass)
+ {
+ case 0:
+ for (size_t i = 0; i < m1; i++)
+ {
+ *p++ = 0xCC;
+ *p++ = 0x99;
+ }
+ for (size_t i = 0; i < m2; i++)
+ {
+ *p++ = 0xCC;
+ *p++ = 0x80;
+ }
+ break;
+
+ case 1:
+ for (size_t i = 0; i < m2; i++)
+ {
+ *p++ = 0xCC;
+ *p++ = 0x80;
+ }
+ for (size_t i = 0; i < m1; i++)
+ {
+ *p++ = 0xCC;
+ *p++ = 0x99;
+ }
+ break;
+
+ case 2:
+ for (size_t i = 0; i < m2; i++)
+ {
+ *p++ = 0xCC;
+ *p++ = 0x99;
+ *p++ = 0xCC;
+ *p++ = 0x80;
+ }
+ for (size_t i = m2; i < m1; i++)
+ {
+ *p++ = 0xCC;
+ *p++ = 0x99;
+ }
+ break;
+
+ default:
+ abort ();
+ }
+
+ expected[0] = 0x41;
+ p = expected + 1;
+ for (size_t i = 0; i < m1; i++)
+ {
+ *p++ = 0xCC;
+ *p++ = 0x99;
+ }
+ for (size_t i = 0; i < m2; i++)
+ {
+ *p++ = 0xCC;
+ *p++ = 0x80;
+ }
+
+ for (; repeat > 0; repeat--)
+ ASSERT (check (input, 2 * m - 1, expected, 2 * m - 1) == 0);
+
+ free (input);
+ }
+ }
}
#else
#endif
/* Check that the sorting is not O(n²) but O(n log n). */
- {
- int pass;
- for (pass = 0; pass < 3; pass++)
- {
- size_t repeat = 1;
- size_t m = 100000;
- uint8_t *input = (uint8_t *) malloc (2 * (2 * m - 1) * sizeof (uint8_t));
- if (input != NULL)
- {
- uint8_t *expected = input + (2 * m - 1);
- size_t m1 = m / 2;
- size_t m2 = (m - 1) / 2;
- /* NB: m1 + m2 == m - 1. */
- uint8_t *p;
- size_t i;
-
- input[0] = 0x41;
- p = input + 1;
- switch (pass)
- {
- case 0:
- for (i = 0; i < m1; i++)
- {
- *p++ = 0xCC;
- *p++ = 0x99;
- }
- for (i = 0; i < m2; i++)
- {
- *p++ = 0xCC;
- *p++ = 0x80;
- }
- break;
-
- case 1:
- for (i = 0; i < m2; i++)
- {
- *p++ = 0xCC;
- *p++ = 0x80;
- }
- for (i = 0; i < m1; i++)
- {
- *p++ = 0xCC;
- *p++ = 0x99;
- }
- break;
-
- case 2:
- for (i = 0; i < m2; i++)
- {
- *p++ = 0xCC;
- *p++ = 0x99;
- *p++ = 0xCC;
- *p++ = 0x80;
- }
- for (; i < m1; i++)
- {
- *p++ = 0xCC;
- *p++ = 0x99;
- }
- break;
-
- default:
- abort ();
- }
-
- expected[0] = 0xC3;
- expected[1] = 0x80;
- p = expected + 2;
- for (i = 0; i < m1; i++)
- {
- *p++ = 0xCC;
- *p++ = 0x99;
- }
- for (i = 0; i < m2 - 1; i++)
- {
- *p++ = 0xCC;
- *p++ = 0x80;
- }
-
- for (; repeat > 0; repeat--)
- {
- ASSERT (check (input, 2 * m - 1, expected, 2 * m - 2) == 0);
- ASSERT (check (expected, 2 * m - 2, expected, 2 * m - 2) == 0);
- }
-
- free (input);
- }
- }
- }
+ for (int pass = 0; pass < 3; pass++)
+ {
+ size_t repeat = 1;
+ size_t m = 100000;
+ uint8_t *input = (uint8_t *) malloc (2 * (2 * m - 1) * sizeof (uint8_t));
+ if (input != NULL)
+ {
+ uint8_t *expected = input + (2 * m - 1);
+ size_t m1 = m / 2;
+ size_t m2 = (m - 1) / 2;
+ /* NB: m1 + m2 == m - 1. */
+ uint8_t *p;
+
+ input[0] = 0x41;
+ p = input + 1;
+ switch (pass)
+ {
+ case 0:
+ for (size_t i = 0; i < m1; i++)
+ {
+ *p++ = 0xCC;
+ *p++ = 0x99;
+ }
+ for (size_t i = 0; i < m2; i++)
+ {
+ *p++ = 0xCC;
+ *p++ = 0x80;
+ }
+ break;
+
+ case 1:
+ for (size_t i = 0; i < m2; i++)
+ {
+ *p++ = 0xCC;
+ *p++ = 0x80;
+ }
+ for (size_t i = 0; i < m1; i++)
+ {
+ *p++ = 0xCC;
+ *p++ = 0x99;
+ }
+ break;
+
+ case 2:
+ for (size_t i = 0; i < m2; i++)
+ {
+ *p++ = 0xCC;
+ *p++ = 0x99;
+ *p++ = 0xCC;
+ *p++ = 0x80;
+ }
+ for (size_t i = m2; i < m1; i++)
+ {
+ *p++ = 0xCC;
+ *p++ = 0x99;
+ }
+ break;
+
+ default:
+ abort ();
+ }
+
+ expected[0] = 0xC3;
+ expected[1] = 0x80;
+ p = expected + 2;
+ for (size_t i = 0; i < m1; i++)
+ {
+ *p++ = 0xCC;
+ *p++ = 0x99;
+ }
+ for (size_t i = 0; i < m2 - 1; i++)
+ {
+ *p++ = 0xCC;
+ *p++ = 0x80;
+ }
+
+ for (; repeat > 0; repeat--)
+ {
+ ASSERT (check (input, 2 * m - 1, expected, 2 * m - 2) == 0);
+ ASSERT (check (expected, 2 * m - 2, expected, 2 * m - 2) == 0);
+ }
+
+ free (input);
+ }
+ }
}
#else
#endif
/* Check that the sorting is not O(n²) but O(n log n). */
- {
- int pass;
- for (pass = 0; pass < 3; pass++)
- {
- size_t repeat = 1;
- size_t m = 100000;
- uint8_t *input = (uint8_t *) malloc (2 * (2 * m - 1) * sizeof (uint8_t));
- if (input != NULL)
- {
- uint8_t *expected = input + (2 * m - 1);
- size_t m1 = m / 2;
- size_t m2 = (m - 1) / 2;
- /* NB: m1 + m2 == m - 1. */
- uint8_t *p;
- size_t i;
-
- input[0] = 0x41;
- p = input + 1;
- switch (pass)
- {
- case 0:
- for (i = 0; i < m1; i++)
- {
- *p++ = 0xCC;
- *p++ = 0x99;
- }
- for (i = 0; i < m2; i++)
- {
- *p++ = 0xCC;
- *p++ = 0x80;
- }
- break;
-
- case 1:
- for (i = 0; i < m2; i++)
- {
- *p++ = 0xCC;
- *p++ = 0x80;
- }
- for (i = 0; i < m1; i++)
- {
- *p++ = 0xCC;
- *p++ = 0x99;
- }
- break;
-
- case 2:
- for (i = 0; i < m2; i++)
- {
- *p++ = 0xCC;
- *p++ = 0x99;
- *p++ = 0xCC;
- *p++ = 0x80;
- }
- for (; i < m1; i++)
- {
- *p++ = 0xCC;
- *p++ = 0x99;
- }
- break;
-
- default:
- abort ();
- }
-
- expected[0] = 0x41;
- p = expected + 1;
- for (i = 0; i < m1; i++)
- {
- *p++ = 0xCC;
- *p++ = 0x99;
- }
- for (i = 0; i < m2; i++)
- {
- *p++ = 0xCC;
- *p++ = 0x80;
- }
-
- for (; repeat > 0; repeat--)
- ASSERT (check (input, 2 * m - 1, expected, 2 * m - 1) == 0);
-
- free (input);
- }
- }
- }
+ for (int pass = 0; pass < 3; pass++)
+ {
+ size_t repeat = 1;
+ size_t m = 100000;
+ uint8_t *input = (uint8_t *) malloc (2 * (2 * m - 1) * sizeof (uint8_t));
+ if (input != NULL)
+ {
+ uint8_t *expected = input + (2 * m - 1);
+ size_t m1 = m / 2;
+ size_t m2 = (m - 1) / 2;
+ /* NB: m1 + m2 == m - 1. */
+ uint8_t *p;
+
+ input[0] = 0x41;
+ p = input + 1;
+ switch (pass)
+ {
+ case 0:
+ for (size_t i = 0; i < m1; i++)
+ {
+ *p++ = 0xCC;
+ *p++ = 0x99;
+ }
+ for (size_t i = 0; i < m2; i++)
+ {
+ *p++ = 0xCC;
+ *p++ = 0x80;
+ }
+ break;
+
+ case 1:
+ for (size_t i = 0; i < m2; i++)
+ {
+ *p++ = 0xCC;
+ *p++ = 0x80;
+ }
+ for (size_t i = 0; i < m1; i++)
+ {
+ *p++ = 0xCC;
+ *p++ = 0x99;
+ }
+ break;
+
+ case 2:
+ for (size_t i = 0; i < m2; i++)
+ {
+ *p++ = 0xCC;
+ *p++ = 0x99;
+ *p++ = 0xCC;
+ *p++ = 0x80;
+ }
+ for (size_t i = m2; i < m1; i++)
+ {
+ *p++ = 0xCC;
+ *p++ = 0x99;
+ }
+ break;
+
+ default:
+ abort ();
+ }
+
+ expected[0] = 0x41;
+ p = expected + 1;
+ for (size_t i = 0; i < m1; i++)
+ {
+ *p++ = 0xCC;
+ *p++ = 0x99;
+ }
+ for (size_t i = 0; i < m2; i++)
+ {
+ *p++ = 0xCC;
+ *p++ = 0x80;
+ }
+
+ for (; repeat > 0; repeat--)
+ ASSERT (check (input, 2 * m - 1, expected, 2 * m - 1) == 0);
+
+ free (input);
+ }
+ }
}
#else
{
struct accumulator accu;
struct uninorm_filter *filter;
- size_t i;
accu.result = NULL;
accu.length = 0;
filter = uninorm_filter_create (UNINORM_NFC, write_to_accumulator, &accu);
ASSERT (filter != NULL);
- for (i = 0; i < input_length; i++)
+ for (size_t i = 0; i < input_length; i++)
ASSERT (uninorm_filter_write (filter, input[i]) == 0);
ASSERT (uninorm_filter_free (filter) == 0);
test_function (uint16_t * (*my_asnprintf) (uint16_t *, size_t *, const char *, ...))
{
uint16_t buf[8];
- int size;
/* Test return value convention. */
- for (size = 0; size <= 8; size++)
+ for (int size = 0; size <= 8; size++)
{
size_t length = size;
uint16_t *result = my_asnprintf (NULL, &length, "%d", 12345);
free (result);
}
- for (size = 0; size <= 8; size++)
+ for (int size = 0; size <= 8; size++)
{
static const uint16_t initializer[] =
{ 'D', 'E', 'A', 'D', 'B', 'E', 'E', 'F', 0 };
test_function (uint32_t * (*my_asnprintf) (uint32_t *, size_t *, const char *, ...))
{
uint32_t buf[8];
- int size;
/* Test return value convention. */
- for (size = 0; size <= 8; size++)
+ for (int size = 0; size <= 8; size++)
{
size_t length = size;
uint32_t *result = my_asnprintf (NULL, &length, "%d", 12345);
free (result);
}
- for (size = 0; size <= 8; size++)
+ for (int size = 0; size <= 8; size++)
{
static const uint32_t initializer[] =
{ 'D', 'E', 'A', 'D', 'B', 'E', 'E', 'F', 0 };
{
ASSERT (u8_strlen (s) == len);
ASSERT (len == n1 + n2 + 3);
- size_t i;
- for (i = 0; i <= len; i++)
+ for (size_t i = 0; i <= len; i++)
s[i] = (i == 0 ? 'x' :
i <= n1 ? 'a' :
i == n1 + 1 ? 'y' :
{
ASSERT (u8_strlen (s) == len);
ASSERT (len == n1 + 2);
- size_t i;
- for (i = 0; i <= len; i++)
+ for (size_t i = 0; i <= len; i++)
s[i] = (i == 0 ? 'x' :
i <= n1 ? 'a' :
i == n1 + 1 ? 'y' :
{
ASSERT (u8_strlen (s) == len);
ASSERT (len == n1 + 2);
- size_t i;
- for (i = 0; i <= len; i++)
+ for (size_t i = 0; i <= len; i++)
s[i] = (i == 0 ? 'x' :
i <= n1 ? 'a' :
i == n1 + 1 ? 'y' :
{
ASSERT (u8_strlen (s) == len);
ASSERT (len == n1 + 2);
- size_t i;
- for (i = 0; i <= len; i++)
+ for (size_t i = 0; i <= len; i++)
s[i] = (i == 0 ? 'x' :
i <= n1 ? 'a' :
i == n1 + 1 ? 'y' :
{
ASSERT (u8_strlen (s) == len);
ASSERT (len == n1 + 2);
- size_t i;
- for (i = 0; i <= len; i++)
+ for (size_t i = 0; i <= len; i++)
s[i] = (i == 0 ? 'x' :
i <= n1 ? 'a' :
i == n1 + 1 ? 'y' :
test_function (uint8_t * (*my_asnprintf) (uint8_t *, size_t *, const char *, ...))
{
uint8_t buf[8];
- int size;
/* Test return value convention. */
- for (size = 0; size <= 8; size++)
+ for (int size = 0; size <= 8; size++)
{
size_t length = size;
uint8_t *result = my_asnprintf (NULL, &length, "%d", 12345);
free (result);
}
- for (size = 0; size <= 8; size++)
+ for (int size = 0; size <= 8; size++)
{
static const uint8_t initializer[] = "DEADBEEF";
static const uint8_t expected[] = "12345";
{
ASSERT (strlen (s) == len);
ASSERT (len == n1 + n2 + 3);
- size_t i;
- for (i = 0; i <= len; i++)
+ for (size_t i = 0; i <= len; i++)
s[i] = (i == 0 ? 'x' :
i <= n1 ? 'a' :
i == n1 + 1 ? 'y' :
{
ASSERT (strlen (s) == len);
ASSERT (len == n1 + 2);
- size_t i;
- for (i = 0; i <= len; i++)
+ for (size_t i = 0; i <= len; i++)
s[i] = (i == 0 ? 'x' :
i <= n1 ? 'a' :
i == n1 + 1 ? 'y' :
{
ASSERT (strlen (s) == len);
ASSERT (len == n1 + 2);
- size_t i;
- for (i = 0; i <= len; i++)
+ for (size_t i = 0; i <= len; i++)
s[i] = (i == 0 ? 'x' :
i <= n1 ? 'a' :
i == n1 + 1 ? 'y' :
{
ASSERT (strlen (s) == len);
ASSERT (len == n1 + 2);
- size_t i;
- for (i = 0; i <= len; i++)
+ for (size_t i = 0; i <= len; i++)
s[i] = (i == 0 ? 'x' :
i <= n1 ? 'a' :
i == n1 + 1 ? 'y' :
{
ASSERT (strlen (s) == len);
ASSERT (len == n1 + 2);
- size_t i;
- for (i = 0; i <= len; i++)
+ for (size_t i = 0; i <= len; i++)
s[i] = (i == 0 ? 'x' :
i <= n1 ? 'a' :
i == n1 + 1 ? 'y' :
{
ASSERT (strlen (s) == len);
ASSERT (len == n1 + 2);
- size_t i;
- for (i = 0; i <= len; i++)
+ for (size_t i = 0; i <= len; i++)
s[i] = (i == 0 ? 'x' :
i <= n1 ? 'a' :
i == n1 + 1 ? 'y' :
{
ASSERT (strlen (s) == len);
ASSERT (len == n1 + 2);
- size_t i;
- for (i = 0; i <= len; i++)
+ for (size_t i = 0; i <= len; i++)
s[i] = (i == 0 ? 'x' :
i <= n1 ? 'a' :
i == n1 + 1 ? 'y' :
test_function (char * (*my_asnprintf) (char *, size_t *, const char *, ...))
{
char buf[8];
- int size;
/* Test return value convention. */
- for (size = 0; size <= 8; size++)
+ for (int size = 0; size <= 8; size++)
{
size_t length = size;
char *result = my_asnprintf (NULL, &length, "%d", 12345);
free (result);
}
- for (size = 0; size <= 8; size++)
+ for (int size = 0; size <= 8; size++)
{
size_t length;
char *result;
}
/* Alignment tests. */
- {
- int i, j;
- for (i = 0; i < 32; i++)
- {
- for (j = 0; j < 128; j++)
- input[i + j] = j;
- for (j = 0; j < 128; j++)
- {
- ASSERT (U_CHR (input + i, 128, j) == input + i + j);
- }
- }
- }
+ for (int i = 0; i < 32; i++)
+ {
+ for (int j = 0; j < 128; j++)
+ input[i + j] = j;
+ for (int j = 0; j < 128; j++)
+ {
+ ASSERT (U_CHR (input + i, 128, j) == input + i + j);
+ }
+ }
/* Check that uN_chr() does not read past the first occurrence of the
byte being searched. */
{
UNIT *page_boundary = zerosize_ptr ();
- size_t n;
if (page_boundary != NULL)
{
- for (n = 1; n <= 500 / sizeof (UNIT); n++)
+ for (size_t n = 1; n <= 500 / sizeof (UNIT); n++)
{
UNIT *mem = page_boundary - n;
U_SET (mem, 'X', n);
ASSERT (U_CHR (mem, n, 'U') == NULL);
- {
- size_t i;
-
- for (i = 0; i < n; i++)
- {
- mem[i] = 'U';
- ASSERT (U_CHR (mem, 4000, 'U') == mem + i);
- mem[i] = 'X';
- }
- }
+ for (size_t i = 0; i < n; i++)
+ {
+ mem[i] = 'U';
+ ASSERT (U_CHR (mem, 4000, 'U') == mem + i);
+ mem[i] = 'X';
+ }
}
}
}
{
UNIT foo[21];
UNIT bar[21];
- int i;
- for (i = 0; i < 4; i++)
+ for (int i = 0; i < 4; i++)
{
UNIT *a = foo + i;
UNIT *b = bar + i;
- int j;
- for (j = 0; j < 8; j++)
+ for (int j = 0; j < 8; j++)
a[j] = '-';
a[8] = '0';
- for (j = 9; j < 16; j++)
+ for (int j = 9; j < 16; j++)
a[j] = '1';
- for (j = 0; j < 8; j++)
+ for (int j = 0; j < 8; j++)
b[j] = '-';
b[8] = '1';
- for (j = 9; j < 16; j++)
+ for (int j = 9; j < 16; j++)
b[j] = '0';
ASSERT (U_CMP (a, b, 16) < 0);
}
/* Test small copying operations. */
{
static const UNIT src[] = { 'c', 'l', 'i', 'm', 'a', 't', 'e' };
- size_t n;
- for (n = 0; n <= SIZEOF (src); n++)
+ for (size_t n = 0; n <= SIZEOF (src); n++)
{
UNIT *result = U_CPY_ALLOC (src, n);
- size_t i;
ASSERT (result != NULL);
- for (i = 0; i < n; i++)
+ for (size_t i = 0; i < n; i++)
ASSERT (result[i] == src[i]);
free (result);
/* Test small copying operations. */
{
static const UNIT src[] = { 'c', 'l', 'i', 'm', 'a', 't', 'e' };
- size_t n;
- for (n = 0; n <= SIZEOF (src); n++)
+ for (size_t n = 0; n <= SIZEOF (src); n++)
{
UNIT dest[1 + SIZEOF (src) + 1] =
{ MAGIC, MAGIC, MAGIC, MAGIC, MAGIC, MAGIC, MAGIC, MAGIC, MAGIC };
UNIT *ret;
- size_t i;
ret = U_CPY (dest + 1, src, n);
ASSERT (ret == dest + 1);
ASSERT (dest[0] == MAGIC);
- for (i = 0; i < n; i++)
+ for (size_t i = 0; i < n; i++)
ASSERT (dest[1 + i] == src[i]);
ASSERT (dest[1 + n] == MAGIC);
}
/* Test copying operations with disjoint source and destination. */
{
static const UNIT src[] = { 'c', 'l', 'i', 'm', 'a', 't', 'e' };
- size_t n;
- for (n = 0; n <= SIZEOF (src); n++)
+ for (size_t n = 0; n <= SIZEOF (src); n++)
{
UNIT dest[1 + SIZEOF (src) + 1] =
{ MAGIC, MAGIC, MAGIC, MAGIC, MAGIC, MAGIC, MAGIC, MAGIC, MAGIC };
UNIT *ret;
- size_t i;
ret = U_MOVE (dest + 1, src, n);
ASSERT (ret == dest + 1);
ASSERT (dest[0] == MAGIC);
- for (i = 0; i < n; i++)
+ for (size_t i = 0; i < n; i++)
ASSERT (dest[1 + i] == src[i]);
ASSERT (dest[1 + n] == MAGIC);
}
/* Test copying operations with overlap, in-place. */
{
static const UNIT src[] = { 'c', 'l', 'i', 'm', 'a', 't', 'e' };
- size_t n;
- for (n = 0; n <= SIZEOF (src); n++)
+ for (size_t n = 0; n <= SIZEOF (src); n++)
{
UNIT dest[1 + SIZEOF (src) + 1];
UNIT *ret;
- size_t i;
dest[0] = MAGIC;
- for (i = 0; i < n; i++)
+ for (size_t i = 0; i < n; i++)
dest[1 + i] = src[i];
dest[1 + n] = MAGIC;
ret = U_MOVE (dest + 1, dest + 1, n);
ASSERT (ret == dest + 1);
ASSERT (dest[0] == MAGIC);
- for (i = 0; i < n; i++)
+ for (size_t i = 0; i < n; i++)
ASSERT (dest[1 + i] == src[i]);
ASSERT (dest[1 + n] == MAGIC);
}
{
static const UNIT src[] = { 'c', 'l', 'i', 'm', 'a', 't', 'e' };
static const UNIT src2[] = { 'C', 'L', 'I', 'M', 'A', 'T', 'E' };
- size_t d;
ASSERT (SIZEOF (src) == SIZEOF (src2));
- for (d = 0; d <= SIZEOF (src); d++)
+ for (size_t d = 0; d <= SIZEOF (src); d++)
{
- size_t n;
-
- for (n = 0; n <= SIZEOF (src); n++)
+ for (size_t n = 0; n <= SIZEOF (src); n++)
{
UNIT dest[1 + 2 * SIZEOF (src) + 1];
UNIT *ret;
- size_t i;
dest[0] = MAGIC;
- for (i = 0; i < SIZEOF (src2); i++)
+ for (size_t i = 0; i < SIZEOF (src2); i++)
dest[1 + i] = src2[i];
- for (i = 0; i < SIZEOF (src); i++)
+ for (size_t i = 0; i < SIZEOF (src); i++)
dest[1 + SIZEOF (src) + i] = src[i];
dest[1 + 2 * SIZEOF (src)] = MAGIC;
U_MOVE (dest + 1 + SIZEOF (src) - d, dest + 1 + SIZEOF (src), n);
ASSERT (ret == dest + 1 + SIZEOF (src) - d);
ASSERT (dest[0] == MAGIC);
- for (i = 0; i < SIZEOF (src) - d; i++)
+ for (size_t i = 0; i < SIZEOF (src) - d; i++)
ASSERT (dest[1 + i] == src2[i]);
- for (i = 0; i < n; i++)
+ for (size_t i = 0; i < n; i++)
ASSERT (dest[1 + SIZEOF (src) - d + i] == src[i]);
- for (i = SIZEOF (src) - d + n; i < SIZEOF (src2); i++)
+ for (size_t i = SIZEOF (src) - d + n; i < SIZEOF (src2); i++)
ASSERT (dest[1 + i] == src2[i]);
- for (i = (n >= d ? n - d : 0); i < SIZEOF (src); i++)
+ for (size_t i = (n >= d ? n - d : 0); i < SIZEOF (src); i++)
ASSERT (dest[1 + SIZEOF (src) + i] == src[i]);
ASSERT (dest[1 + 2 * SIZEOF (src)] == MAGIC);
}
{
static const UNIT src[] = { 'c', 'l', 'i', 'm', 'a', 't', 'e' };
static const UNIT src2[] = { 'C', 'L', 'I', 'M', 'A', 'T', 'E' };
- size_t d;
ASSERT (SIZEOF (src) == SIZEOF (src2));
- for (d = 0; d <= SIZEOF (src); d++)
+ for (size_t d = 0; d <= SIZEOF (src); d++)
{
- size_t n;
-
- for (n = 0; n <= SIZEOF (src); n++)
+ for (size_t n = 0; n <= SIZEOF (src); n++)
{
UNIT dest[1 + 2 * SIZEOF (src) + 1];
UNIT *ret;
- size_t i;
dest[0] = MAGIC;
- for (i = 0; i < SIZEOF (src); i++)
+ for (size_t i = 0; i < SIZEOF (src); i++)
dest[1 + i] = src[i];
- for (i = 0; i < SIZEOF (src2); i++)
+ for (size_t i = 0; i < SIZEOF (src2); i++)
dest[1 + SIZEOF (src) + i] = src2[i];
dest[1 + 2 * SIZEOF (src)] = MAGIC;
ret = U_MOVE (dest + 1 + d, dest + 1, n);
ASSERT (ret == dest + 1 + d);
ASSERT (dest[0] == MAGIC);
- for (i = 0; i < d; i++)
+ for (size_t i = 0; i < d; i++)
ASSERT (dest[1 + i] == src[i]);
- for (i = 0; i < n; i++)
+ for (size_t i = 0; i < n; i++)
ASSERT (dest[1 + d + i] == src[i]);
- for (i = d + n; i < SIZEOF (src); i++)
+ for (size_t i = d + n; i < SIZEOF (src); i++)
ASSERT (dest[1 + i] == src[i]);
- for (i = (d + n >= SIZEOF (src) ? d + n - SIZEOF (src) : 0);
+ for (size_t i = (d + n >= SIZEOF (src) ? d + n - SIZEOF (src) : 0);
i < SIZEOF (src2);
i++)
ASSERT (dest[1 + SIZEOF (src) + i] == src2[i]);
/* Test small copying operations. */
{
static const UNIT src[] = { 'c', 'l', 'i', 'm', 'a', 't', 'e' };
- size_t n;
- for (n = 0; n <= SIZEOF (src); n++)
+ for (size_t n = 0; n <= SIZEOF (src); n++)
{
UNIT dest[1 + SIZEOF (src) + 1] =
{ MAGIC, MAGIC, MAGIC, MAGIC, MAGIC, MAGIC, MAGIC, MAGIC, MAGIC };
UNIT *ret;
- size_t i;
ret = U_PCPY (dest + 1, src, n);
ASSERT (ret == dest + 1 + n);
ASSERT (dest[0] == MAGIC);
- for (i = 0; i < n; i++)
+ for (size_t i = 0; i < n; i++)
ASSERT (dest[1 + i] == src[i]);
ASSERT (dest[1 + n] == MAGIC);
}
int
main ()
{
- {
#define NMAX 7
- size_t n;
-
- for (n = 0; n <= NMAX; n++)
- {
- UNIT dest[1 + NMAX + 1] =
- { MAGIC, MAGIC, MAGIC, MAGIC, MAGIC, MAGIC, MAGIC, MAGIC, MAGIC };
- UNIT *ret;
- size_t i;
-
- ret = U_SET (dest + 1, VALUE, n);
- ASSERT (ret == dest + 1);
- ASSERT (dest[0] == MAGIC);
- for (i = 0; i < n; i++)
- ASSERT (dest[1 + i] == VALUE);
- ASSERT (dest[1 + n] == MAGIC);
- }
+ for (size_t n = 0; n <= NMAX; n++)
+ {
+ UNIT dest[1 + NMAX + 1] =
+ { MAGIC, MAGIC, MAGIC, MAGIC, MAGIC, MAGIC, MAGIC, MAGIC, MAGIC };
+ UNIT *ret;
+
+ ret = U_SET (dest + 1, VALUE, n);
+ ASSERT (ret == dest + 1);
+ ASSERT (dest[0] == MAGIC);
+ for (size_t i = 0; i < n; i++)
+ ASSERT (dest[1 + i] == VALUE);
+ ASSERT (dest[1 + n] == MAGIC);
+ }
#undef NMAX
- }
return test_exit_status;
}
/* Test small copying operations. */
{
static const UNIT src[] = { 'c', 'l', 'i', 'm', 'a', 't', 'e', 0 };
- size_t n;
- for (n = 1; n <= SIZEOF (src); n++)
+ for (size_t n = 1; n <= SIZEOF (src); n++)
{
UNIT dest[1 + SIZEOF (src) + 1] =
{ MAGIC, MAGIC, MAGIC, MAGIC, MAGIC, MAGIC, MAGIC, MAGIC, MAGIC,
MAGIC
};
UNIT *result;
- size_t i;
result = U_STPCPY (dest + 1, src + SIZEOF (src) - n);
ASSERT (result == dest + n);
ASSERT (dest[0] == MAGIC);
- for (i = 0; i < n; i++)
+ for (size_t i = 0; i < n; i++)
ASSERT (dest[1 + i] == src[SIZEOF (src) - n + i]);
ASSERT (dest[1 + n] == MAGIC);
}
{
UNIT *dest;
UNIT *result;
- size_t i;
dest = (UNIT *) malloc ((1 + n + 1) * sizeof (UNIT));
ASSERT (dest != NULL);
- for (i = 0; i < 1 + n + 1; i++)
+ for (size_t i = 0; i < 1 + n + 1; i++)
dest[i] = MAGIC;
result = U_STPNCPY (dest + 1, input, n);
ASSERT (result == dest + 1 + (n <= length ? n : length));
ASSERT (dest[0] == MAGIC);
- for (i = 0; i < (n <= length ? n : length + 1); i++)
- ASSERT (dest[1 + i] == input[i]);
- for (; i < n; i++)
- ASSERT (dest[1 + i] == 0);
+ {
+ size_t i;
+ for (i = 0; i < (n <= length ? n : length + 1); i++)
+ ASSERT (dest[1 + i] == input[i]);
+ for (; i < n; i++)
+ ASSERT (dest[1 + i] == 0);
+ }
ASSERT (dest[1 + n] == MAGIC);
free (dest);
check (const UNIT *input, size_t input_length)
{
size_t length;
- size_t n;
ASSERT (input_length > 0);
ASSERT (input[input_length - 1] == 0);
length = input_length - 1; /* = U_STRLEN (input) */
- for (n = 0; n <= 2 * length + 2; n++)
+ for (size_t n = 0; n <= 2 * length + 2; n++)
check_single (input, length, n);
/* Check that U_STPNCPY (D, S, N) does not look at more than
if (page_boundary != NULL)
{
- for (n = 0; n <= 2 * length + 2; n++)
+ for (size_t n = 0; n <= 2 * length + 2; n++)
{
size_t n_to_copy = (n <= length ? n : length + 1);
UNIT *copy;
- size_t i;
copy = (UNIT *) page_boundary - n_to_copy;
- for (i = 0; i < n_to_copy; i++)
+ for (size_t i = 0; i < n_to_copy; i++)
copy[i] = input[i];
check_single (copy, length, n);
{
static const UNIT base[] = { 'C', 'h', 'a', 'n', 'g', 'i', 'n', 'g', 0 };
static const UNIT src[] = { 'c', 'l', 'i', 'm', 'a', 't', 'e', 0 };
- size_t m;
- size_t n;
- for (m = 0; m < SIZEOF (base); m++)
- for (n = 1; n <= SIZEOF (src); n++)
+ for (size_t m = 0; m < SIZEOF (base); m++)
+ for (size_t n = 1; n <= SIZEOF (src); n++)
{
UNIT dest[1 + (SIZEOF (base) - 1) + SIZEOF (src) + 1] =
{ MAGIC, MAGIC, MAGIC, MAGIC, MAGIC, MAGIC, MAGIC, MAGIC, MAGIC,
MAGIC, MAGIC, MAGIC, MAGIC, MAGIC, MAGIC, MAGIC, MAGIC, MAGIC
};
UNIT *result;
- size_t i;
- for (i = 0; i < m; i++)
+ for (size_t i = 0; i < m; i++)
dest[1 + i] = base[i];
dest[1 + m] = 0;
ASSERT (result == dest + 1);
ASSERT (dest[0] == MAGIC);
- for (i = 0; i < m; i++)
+ for (size_t i = 0; i < m; i++)
ASSERT (dest[1 + i] == base[i]);
- for (i = 0; i < n; i++)
+ for (size_t i = 0; i < n; i++)
ASSERT (dest[1 + m + i] == src[SIZEOF (src) - n + i]);
ASSERT (dest[1 + m + n] == MAGIC);
}
}
/* Alignment tests. */
- {
- int i, j;
- for (i = 0; i < 32; i++)
- {
- for (j = 0; j < 127; j++)
- input[i + j] = j + 1;
- input[i + 128] = 0;
- for (j = 0; j < 127; j++)
- {
- ASSERT (U_STRCHR (input + i, j + 1) == input + i + j);
- }
- }
- }
+ for (int i = 0; i < 32; i++)
+ {
+ for (int j = 0; j < 127; j++)
+ input[i + j] = j + 1;
+ input[i + 128] = 0;
+ for (int j = 0; j < 127; j++)
+ {
+ ASSERT (U_STRCHR (input + i, j + 1) == input + i + j);
+ }
+ }
/* Check that uN_strchr() does not read past the end of the string. */
{
char *page_boundary = (char *) zerosize_ptr ();
- size_t n;
if (page_boundary != NULL)
{
- for (n = 2; n <= 500 / sizeof (UNIT); n++)
+ for (size_t n = 2; n <= 500 / sizeof (UNIT); n++)
{
UNIT *mem = (UNIT *) (page_boundary - n * sizeof (UNIT));
U_SET (mem, 'X', n - 2);
byte being searched. */
{
char *page_boundary = (char *) zerosize_ptr ();
- size_t n;
if (page_boundary != NULL)
{
- for (n = 2; n <= 500 / sizeof (UNIT); n++)
+ for (size_t n = 2; n <= 500 / sizeof (UNIT); n++)
{
UNIT *mem = (UNIT *) (page_boundary - n * sizeof (UNIT));
U_SET (mem, 'X', n - 1);
mem[n - 1] = 0;
ASSERT (U_STRCHR (mem, 'U') == NULL);
- {
- size_t i;
-
- for (i = 0; i < n; i++)
- {
- mem[i] = 'U';
- ASSERT (U_STRCHR (mem, 'U') == mem + i);
- mem[i] = 'X';
- }
- }
+ for (size_t i = 0; i < n; i++)
+ {
+ mem[i] = 'U';
+ ASSERT (U_STRCHR (mem, 'U') == mem + i);
+ mem[i] = 'X';
+ }
}
}
}
/* Test small copying operations. */
{
static const UNIT src[] = { 'c', 'l', 'i', 'm', 'a', 't', 'e', 0 };
- size_t n;
- for (n = 1; n <= SIZEOF (src); n++)
+ for (size_t n = 1; n <= SIZEOF (src); n++)
{
UNIT dest[1 + SIZEOF (src) + 1] =
{ MAGIC, MAGIC, MAGIC, MAGIC, MAGIC, MAGIC, MAGIC, MAGIC, MAGIC,
MAGIC
};
UNIT *result;
- size_t i;
result = U_STRCPY (dest + 1, src + SIZEOF (src) - n);
ASSERT (result == dest + 1);
ASSERT (dest[0] == MAGIC);
- for (i = 0; i < n; i++)
+ for (size_t i = 0; i < n; i++)
ASSERT (dest[1 + i] == src[SIZEOF (src) - n + i]);
ASSERT (dest[1 + n] == MAGIC);
}
/* Test small copying operations. */
{
static const UNIT src[] = { 'c', 'l', 'i', 'm', 'a', 't', 'e', 0 };
- size_t n;
- for (n = 1; n <= SIZEOF (src); n++)
+ for (size_t n = 1; n <= SIZEOF (src); n++)
{
UNIT *result = U_STRDUP (src + SIZEOF (src) - n);
- size_t i;
ASSERT (result != NULL);
- for (i = 0; i < n; i++)
+ for (size_t i = 0; i < n; i++)
ASSERT (result[i] == src[SIZEOF (src) - n + i]);
free (result);
check_single (const UNIT *input, size_t length, size_t n)
{
static const UNIT base[] = { 'C', 'h', 'a', 'n', 'g', 'i', 'n', 'g', 0 };
- size_t m;
- for (m = 0; m < SIZEOF (base); m++)
+ for (size_t m = 0; m < SIZEOF (base); m++)
{
UNIT *dest;
UNIT *result;
- size_t i;
dest = (UNIT *) malloc ((1 + m + n + 2) * sizeof (UNIT));
ASSERT (dest != NULL);
dest[0] = MAGIC;
- for (i = 0; i < m; i++)
+ for (size_t i = 0; i < m; i++)
dest[1 + i] = base[i];
dest[1 + m] = 0;
- for (i = 1; i < n + 2; i++)
+ for (size_t i = 1; i < n + 2; i++)
dest[1 + m + i] = MAGIC;
result = U_STRNCAT (dest + 1, input, n);
ASSERT (result == dest + 1);
ASSERT (dest[0] == MAGIC);
- for (i = 0; i < m; i++)
+ for (size_t i = 0; i < m; i++)
ASSERT (dest[1 + i] == base[i]);
- for (i = 0; i < (n <= length ? n : length); i++)
- ASSERT (dest[1 + m + i] == input[i]);
- ASSERT (dest[1 + m + i] == 0);
- ASSERT (dest[1 + m + i + 1] == MAGIC);
+ {
+ size_t i;
+ for (i = 0; i < (n <= length ? n : length); i++)
+ ASSERT (dest[1 + m + i] == input[i]);
+ ASSERT (dest[1 + m + i] == 0);
+ ASSERT (dest[1 + m + i + 1] == MAGIC);
+ }
free (dest);
}
check (const UNIT *input, size_t input_length)
{
size_t length;
- size_t n;
ASSERT (input_length > 0);
ASSERT (input[input_length - 1] == 0);
length = input_length - 1; /* = U_STRLEN (input) */
- for (n = 0; n <= 2 * length + 2; n++)
+ for (size_t n = 0; n <= 2 * length + 2; n++)
check_single (input, length, n);
/* Check that U_STRNCAT (D, S, N) does not look at more than
if (page_boundary != NULL)
{
- for (n = 0; n <= 2 * length + 2; n++)
+ for (size_t n = 0; n <= 2 * length + 2; n++)
{
size_t n_to_copy = (n <= length ? n : length + 1);
UNIT *copy;
- size_t i;
copy = (UNIT *) page_boundary - n_to_copy;
- for (i = 0; i < n_to_copy; i++)
+ for (size_t i = 0; i < n_to_copy; i++)
copy[i] = input[i];
check_single (copy, length, n);
{
UNIT *dest;
UNIT *result;
- size_t i;
dest = (UNIT *) malloc ((1 + n + 1) * sizeof (UNIT));
ASSERT (dest != NULL);
- for (i = 0; i < 1 + n + 1; i++)
+ for (size_t i = 0; i < 1 + n + 1; i++)
dest[i] = MAGIC;
result = U_STRNCPY (dest + 1, input, n);
ASSERT (result == dest + 1);
ASSERT (dest[0] == MAGIC);
- for (i = 0; i < (n <= length ? n : length + 1); i++)
- ASSERT (dest[1 + i] == input[i]);
- for (; i < n; i++)
- ASSERT (dest[1 + i] == 0);
+ {
+ size_t i;
+ for (i = 0; i < (n <= length ? n : length + 1); i++)
+ ASSERT (dest[1 + i] == input[i]);
+ for (; i < n; i++)
+ ASSERT (dest[1 + i] == 0);
+ }
ASSERT (dest[1 + n] == MAGIC);
free (dest);
check (const UNIT *input, size_t input_length)
{
size_t length;
- size_t n;
ASSERT (input_length > 0);
ASSERT (input[input_length - 1] == 0);
length = input_length - 1; /* = U_STRLEN (input) */
- for (n = 0; n <= 2 * length + 2; n++)
+ for (size_t n = 0; n <= 2 * length + 2; n++)
check_single (input, length, n);
/* Check that U_STRNCPY (D, S, N) does not look at more than
if (page_boundary != NULL)
{
- for (n = 0; n <= 2 * length + 2; n++)
+ for (size_t n = 0; n <= 2 * length + 2; n++)
{
size_t n_to_copy = (n <= length ? n : length + 1);
UNIT *copy;
- size_t i;
copy = (UNIT *) page_boundary - n_to_copy;
- for (i = 0; i < n_to_copy; i++)
+ for (size_t i = 0; i < n_to_copy; i++)
copy[i] = input[i];
check_single (copy, length, n);
check (const UNIT *input, size_t input_length)
{
size_t length;
- size_t n;
ASSERT (input_length > 0);
ASSERT (input[input_length - 1] == 0);
length = input_length - 1; /* = U_STRLEN (input) */
- for (n = 0; n <= 2 * length + 2; n++)
+ for (size_t n = 0; n <= 2 * length + 2; n++)
check_single (input, length, n);
/* Check that U_STRNLEN (S, N) does not look at more than
if (page_boundary != NULL)
{
- for (n = 0; n <= 2 * length + 2; n++)
+ for (size_t n = 0; n <= 2 * length + 2; n++)
{
size_t n_to_copy = (n <= length ? n : length + 1);
UNIT *copy;
- size_t i;
copy = (UNIT *) page_boundary - n_to_copy;
- for (i = 0; i < n_to_copy; i++)
+ for (size_t i = 0; i < n_to_copy; i++)
copy[i] = input[i];
check_single (copy, length, n);
UNIT *haystack = (UNIT *) malloc ((m + 1) * sizeof (UNIT));
if (haystack != NULL)
{
- size_t i;
-
haystack[0] = 'B';
- for (i = 1; i < m; i++)
+ for (size_t i = 1; i < m; i++)
haystack[i] = 'A';
haystack[m] = '\0';
UNIT *needle = (UNIT *) malloc ((m + 1) * sizeof (UNIT));
if (needle != NULL)
{
- size_t i;
-
- for (i = 0; i < m; i++)
+ for (size_t i = 0; i < m; i++)
needle[i] = 'A';
needle[m] = '\0';
UNIT *needle = (UNIT *) malloc ((m + 2) * sizeof (UNIT));
if (haystack != NULL && needle != NULL)
{
- size_t i;
const UNIT *result;
- for (i = 0; i < 2 * m; i++)
+ for (size_t i = 0; i < 2 * m; i++)
haystack[i] = 'A';
haystack[2 * m] = 'B';
haystack[2 * m + 1] = 0;
- for (i = 0; i < m; i++)
+ for (size_t i = 0; i < m; i++)
needle[i] = 'A';
needle[m] = 'B';
needle[m + 1] = 0;
/* Test ISO 646 unit input. */
{
- ucs4_t c;
uint16_t buf[1];
- for (c = 1; c < 0x80; c++)
+ for (ucs4_t c = 1; c < 0x80; c++)
{
buf[0] = c;
ret = u16_mblen (buf, 1);
'-', '4', 'a', 'c', ')', ')', '/', '(', '2', 'a', ')', ' ', ' ',
0x65E5, 0x672C, 0x8A9E, ',', 0x4E2D, 0x6587, ',', 0xD55C, 0xAE00, '\n'
};
- size_t n;
- for (n = 0; n <= SIZEOF (input); n++)
+ for (size_t n = 0; n <= SIZEOF (input); n++)
{
size_t len = u16_mbsnlen (input, n);
ASSERT (len == n);
1, 2, 3, 3, 4, 5, 5, 6, 7,
8, 8, 9, 10, 10
};
- size_t n;
- for (n = 0; n <= SIZEOF (input); n++)
+ for (size_t n = 0; n <= SIZEOF (input); n++)
{
size_t len = u16_mbsnlen (input, n);
ASSERT (len == expected[n]);
/* Test ISO 646 unit input. */
{
- ucs4_t c;
uint16_t buf[1];
- for (c = 0; c < 0x80; c++)
+ for (ucs4_t c = 0; c < 0x80; c++)
{
buf[0] = c;
uc = 0xBADFACE;
/* Test ISO 646 unit input. */
{
- ucs4_t c;
uint16_t buf[1];
- for (c = 0; c < 0x80; c++)
+ for (ucs4_t c = 0; c < 0x80; c++)
{
buf[0] = c;
uc = 0xBADFACE;
/* Test ISO 646 unit input. */
{
- ucs4_t c;
uint16_t buf[2];
- for (c = 1; c < 0x80; c++)
+ for (ucs4_t c = 1; c < 0x80; c++)
{
buf[0] = c;
buf[1] = 0;
{
uint16_t buf[100];
uint16_t *ptr;
- size_t i;
ucs4_t uc1;
ptr = buf;
*ptr++ = 0x2102;
- for (i = 0; i < input_length; i++)
+ for (size_t i = 0; i < input_length; i++)
ptr[i] = input[i];
if (u16_prev (&uc1, ptr + input_length, buf) != ptr)
{
uint16_t buf[100];
uint16_t *ptr;
- size_t i;
ucs4_t uc1;
ptr = buf;
*ptr++ = 0xD835;
*ptr++ = 0xDD1E;
- for (i = 0; i < input_length; i++)
+ for (size_t i = 0; i < input_length; i++)
ptr[i] = input[i];
if (u16_prev (&uc1, ptr + input_length, buf) != ptr)
{
uint16_t buf[100];
uint16_t *ptr;
- size_t i;
ptr = buf;
*ptr++ = 0x2102;
- for (i = 0; i < input_length; i++)
+ for (size_t i = 0; i < input_length; i++)
ptr[i] = input[i];
uc = 0xBADFACE;
{
uint16_t buf[100];
uint16_t *ptr;
- size_t i;
ptr = buf;
*ptr++ = 0xD835;
*ptr++ = 0xDD1E;
- for (i = 0; i < input_length; i++)
+ for (size_t i = 0; i < input_length; i++)
ptr[i] = input[i];
uc = 0xBADFACE;
/* Test ISO 646 unit input. */
{
- ucs4_t c;
uint16_t buf[1];
- for (c = 0; c < 0x80; c++)
+ for (ucs4_t c = 0; c < 0x80; c++)
{
buf[0] = c;
uc = 0xBADFACE;
/* Test ISO 646 unit input. */
{
- ucs4_t c;
uint16_t buf[2];
- for (c = 1; c < 0x80; c++)
+ for (ucs4_t c = 1; c < 0x80; c++)
{
buf[0] = c;
buf[1] = 0;
/* Test ISO 646 unit input. */
{
- ucs4_t c;
uint16_t buf[2];
- for (c = 1; c < 0x80; c++)
+ for (ucs4_t c = 1; c < 0x80; c++)
{
buf[0] = c;
buf[1] = 0;
main ()
{
/* Test ISO 646 character, in particular the NUL character. */
- {
- ucs4_t uc;
-
- for (uc = 0; uc < 0x80; uc++)
- {
- uint16_t buf[3] = { MAGIC, MAGIC, MAGIC };
- int ret;
+ for (ucs4_t uc = 0; uc < 0x80; uc++)
+ {
+ uint16_t buf[3] = { MAGIC, MAGIC, MAGIC };
+ int ret;
- ret = u16_uctomb (buf, uc, 0);
- ASSERT (ret == -2);
- ASSERT (buf[0] == MAGIC);
+ ret = u16_uctomb (buf, uc, 0);
+ ASSERT (ret == -2);
+ ASSERT (buf[0] == MAGIC);
- ret = u16_uctomb (buf, uc, 1);
- ASSERT (ret == 1);
- ASSERT (buf[0] == uc);
- ASSERT (buf[1] == MAGIC);
- }
- }
+ ret = u16_uctomb (buf, uc, 1);
+ ASSERT (ret == 1);
+ ASSERT (buf[0] == uc);
+ ASSERT (buf[1] == MAGIC);
+ }
/* Test BMP character. */
{
{
ucs4_t invalid[] = { 0x110000, 0xD800, 0xDBFF, 0xDC00, 0xDFFF };
uint16_t buf[3] = { MAGIC, MAGIC, MAGIC };
- size_t i;
- for (i = 0; i < SIZEOF (invalid); i++)
+ for (size_t i = 0; i < SIZEOF (invalid); i++)
{
ucs4_t uc = invalid[i];
- int n;
- for (n = 0; n <= 2; n++)
+ for (int n = 0; n <= 2; n++)
{
int ret = u16_uctomb (buf, uc, n);
ASSERT (ret == -1);
/* Test ISO 646 unit input. */
{
- ucs4_t c;
uint32_t buf[1];
- for (c = 1; c < 0x80; c++)
+ for (ucs4_t c = 1; c < 0x80; c++)
{
buf[0] = c;
ret = u32_mblen (buf, 1);
'-', '4', 'a', 'c', ')', ')', '/', '(', '2', 'a', ')', ' ', ' ',
0x65E5, 0x672C, 0x8A9E, ',', 0x4E2D, 0x6587, ',', 0xD55C, 0xAE00, '\n'
};
- size_t n;
- for (n = 0; n <= SIZEOF (input); n++)
+ for (size_t n = 0; n <= SIZEOF (input); n++)
{
size_t len = u32_mbsnlen (input, n);
ASSERT (len == n);
{ '-', '(', 0x1D51E, 0x00D7, 0x1D51F, ')', '=',
0x1D51F, 0x00D7, 0x1D51E
};
- size_t n;
- for (n = 0; n <= SIZEOF (input); n++)
+ for (size_t n = 0; n <= SIZEOF (input); n++)
{
size_t len = u32_mbsnlen (input, n);
ASSERT (len == n);
/* Test ISO 646 unit input. */
{
- ucs4_t c;
uint32_t buf[1];
- for (c = 0; c < 0x80; c++)
+ for (ucs4_t c = 0; c < 0x80; c++)
{
buf[0] = c;
uc = 0xBADFACE;
/* Test ISO 646 unit input. */
{
- ucs4_t c;
uint32_t buf[1];
- for (c = 0; c < 0x80; c++)
+ for (ucs4_t c = 0; c < 0x80; c++)
{
buf[0] = c;
uc = 0xBADFACE;
/* Test ISO 646 unit input. */
{
- ucs4_t c;
uint32_t buf[2];
- for (c = 1; c < 0x80; c++)
+ for (ucs4_t c = 1; c < 0x80; c++)
{
buf[0] = c;
buf[1] = 0;
{
uint32_t buf[100];
uint32_t *ptr;
- size_t i;
ucs4_t uc1;
ptr = buf;
*ptr++ = 0x1D51E;
- for (i = 0; i < input_length; i++)
+ for (size_t i = 0; i < input_length; i++)
ptr[i] = input[i];
if (u32_prev (&uc1, ptr + input_length, buf) != ptr)
{
uint32_t buf[100];
uint32_t *ptr;
- size_t i;
ptr = buf;
*ptr++ = 0x1D51E;
- for (i = 0; i < input_length; i++)
+ for (size_t i = 0; i < input_length; i++)
ptr[i] = input[i];
uc = 0xBADFACE;
/* Test ISO 646 unit input. */
{
- ucs4_t c;
uint32_t buf[1];
- for (c = 0; c < 0x80; c++)
+ for (ucs4_t c = 0; c < 0x80; c++)
{
buf[0] = c;
uc = 0xBADFACE;
/* Test ISO 646 unit input. */
{
- ucs4_t c;
uint32_t buf[2];
- for (c = 1; c < 0x80; c++)
+ for (ucs4_t c = 1; c < 0x80; c++)
{
buf[0] = c;
buf[1] = 0;
/* Test ISO 646 unit input. */
{
- ucs4_t c;
uint32_t buf[2];
- for (c = 1; c < 0x80; c++)
+ for (ucs4_t c = 1; c < 0x80; c++)
{
buf[0] = c;
buf[1] = 0;
main ()
{
/* Test ISO 646 character, in particular the NUL character. */
- {
- ucs4_t uc;
-
- for (uc = 0; uc < 0x80; uc++)
- {
- uint32_t buf[2] = { MAGIC, MAGIC };
- int ret;
+ for (ucs4_t uc = 0; uc < 0x80; uc++)
+ {
+ uint32_t buf[2] = { MAGIC, MAGIC };
+ int ret;
- ret = u32_uctomb (buf, uc, 0);
- ASSERT (ret == -2);
- ASSERT (buf[0] == MAGIC);
+ ret = u32_uctomb (buf, uc, 0);
+ ASSERT (ret == -2);
+ ASSERT (buf[0] == MAGIC);
- ret = u32_uctomb (buf, uc, 1);
- ASSERT (ret == 1);
- ASSERT (buf[0] == uc);
- ASSERT (buf[1] == MAGIC);
- }
- }
+ ret = u32_uctomb (buf, uc, 1);
+ ASSERT (ret == 1);
+ ASSERT (buf[0] == uc);
+ ASSERT (buf[1] == MAGIC);
+ }
/* Test BMP character. */
{
{
ucs4_t invalid[] = { 0x110000, 0xD800, 0xDBFF, 0xDC00, 0xDFFF };
uint32_t buf[2] = { MAGIC, MAGIC };
- size_t i;
- for (i = 0; i < SIZEOF (invalid); i++)
+ for (size_t i = 0; i < SIZEOF (invalid); i++)
{
ucs4_t uc = invalid[i];
- int n;
- for (n = 0; n <= 2; n++)
+ for (int n = 0; n <= 2; n++)
{
int ret = u32_uctomb (buf, uc, n);
ASSERT (ret == -1);
/* Test ISO 646 unit input. */
{
- ucs4_t c;
uint8_t buf[1];
- for (c = 1; c < 0x80; c++)
+ for (ucs4_t c = 1; c < 0x80; c++)
{
buf[0] = c;
ret = u8_mblen (buf, 1);
56, 56, 56, 57, 57, 57, 58,
59, 59, 59, 60, 60, 60, 61
};
- size_t n;
- for (n = 0; n <= SIZEOF (input); n++)
+ for (size_t n = 0; n <= SIZEOF (input); n++)
{
size_t len = u8_mbsnlen (input, n);
ASSERT (len == expected[n]);
}
/* 3.2. Lonely start characters. */
{
- ucs4_t c;
uint8_t input[2];
- for (c = 0xC0; c <= 0xFF; c++)
+ for (ucs4_t c = 0xC0; c <= 0xFF; c++)
{
input[0] = c;
input[1] = ' ';
}
/* 3.2. Lonely start characters. */
{
- ucs4_t c;
uint8_t input[2];
- for (c = 0xC0; c <= 0xFF; c++)
+ for (ucs4_t c = 0xC0; c <= 0xFF; c++)
{
input[0] = c;
input[1] = ' ';
/* Test ISO 646 unit input. */
{
- ucs4_t c;
uint8_t buf[1];
- for (c = 0; c < 0x80; c++)
+ for (ucs4_t c = 0; c < 0x80; c++)
{
buf[0] = c;
uc = 0xBADFACE;
/* Test ISO 646 unit input. */
{
- ucs4_t c;
uint8_t buf[1];
- for (c = 0; c < 0x80; c++)
+ for (ucs4_t c = 0; c < 0x80; c++)
{
buf[0] = c;
uc = 0xBADFACE;
/* Test ISO 646 unit input. */
{
- ucs4_t c;
uint8_t buf[2];
- for (c = 1; c < 0x80; c++)
+ for (ucs4_t c = 1; c < 0x80; c++)
{
buf[0] = c;
buf[1] = 0;
{
uint8_t buf[100];
uint8_t *ptr;
- size_t i;
ucs4_t uc1;
ptr = buf;
*ptr++ = 'x';
- for (i = 0; i < input_length; i++)
+ for (size_t i = 0; i < input_length; i++)
ptr[i] = input[i];
if (u8_prev (&uc1, ptr + input_length, buf) != ptr)
{
uint8_t buf[100];
uint8_t *ptr;
- size_t i;
ucs4_t uc1;
ptr = buf;
*ptr++ = 0xC3;
*ptr++ = 0x97;
- for (i = 0; i < input_length; i++)
+ for (size_t i = 0; i < input_length; i++)
ptr[i] = input[i];
if (u8_prev (&uc1, ptr + input_length, buf) != ptr)
{
uint8_t buf[100];
uint8_t *ptr;
- size_t i;
ucs4_t uc1;
ptr = buf;
*ptr++ = 0xE2;
*ptr++ = 0x84;
*ptr++ = 0x82;
- for (i = 0; i < input_length; i++)
+ for (size_t i = 0; i < input_length; i++)
ptr[i] = input[i];
if (u8_prev (&uc1, ptr + input_length, buf) != ptr)
{
uint8_t buf[100];
uint8_t *ptr;
- size_t i;
ucs4_t uc1;
ptr = buf;
*ptr++ = 0x9D;
*ptr++ = 0x94;
*ptr++ = 0x9E;
- for (i = 0; i < input_length; i++)
+ for (size_t i = 0; i < input_length; i++)
ptr[i] = input[i];
if (u8_prev (&uc1, ptr + input_length, buf) != ptr)
{
uint8_t buf[100];
uint8_t *ptr;
- size_t i;
ptr = buf;
*ptr++ = 'x';
- for (i = 0; i < input_length; i++)
+ for (size_t i = 0; i < input_length; i++)
ptr[i] = input[i];
uc = 0xBADFACE;
{
uint8_t buf[100];
uint8_t *ptr;
- size_t i;
ptr = buf;
*ptr++ = 0xC3;
*ptr++ = 0x97;
- for (i = 0; i < input_length; i++)
+ for (size_t i = 0; i < input_length; i++)
ptr[i] = input[i];
uc = 0xBADFACE;
{
uint8_t buf[100];
uint8_t *ptr;
- size_t i;
ptr = buf;
*ptr++ = 0xE2;
*ptr++ = 0x84;
*ptr++ = 0x82;
- for (i = 0; i < input_length; i++)
+ for (size_t i = 0; i < input_length; i++)
ptr[i] = input[i];
uc = 0xBADFACE;
{
uint8_t buf[100];
uint8_t *ptr;
- size_t i;
ptr = buf;
*ptr++ = 0xF0;
*ptr++ = 0x9D;
*ptr++ = 0x94;
*ptr++ = 0x9E;
- for (i = 0; i < input_length; i++)
+ for (size_t i = 0; i < input_length; i++)
ptr[i] = input[i];
uc = 0xBADFACE;
/* Test ISO 646 unit input. */
{
- ucs4_t c;
uint8_t buf[1];
- for (c = 0; c < 0x80; c++)
+ for (ucs4_t c = 0; c < 0x80; c++)
{
buf[0] = c;
uc = 0xBADFACE;
/* Test ISO 646 unit input. */
{
- ucs4_t c;
uint8_t buf[2];
- for (c = 1; c < 0x80; c++)
+ for (ucs4_t c = 1; c < 0x80; c++)
{
buf[0] = c;
buf[1] = 0;
/* Test ISO 646 unit input. */
{
- ucs4_t c;
uint8_t buf[2];
- for (c = 1; c < 0x80; c++)
+ for (ucs4_t c = 1; c < 0x80; c++)
{
buf[0] = c;
buf[1] = 0;
main ()
{
/* Test ISO 646 character, in particular the NUL character. */
- {
- ucs4_t uc;
-
- for (uc = 0; uc < 0x80; uc++)
- {
- uint8_t buf[5] = { MAGIC, MAGIC, MAGIC, MAGIC, MAGIC };
- int ret;
+ for (ucs4_t uc = 0; uc < 0x80; uc++)
+ {
+ uint8_t buf[5] = { MAGIC, MAGIC, MAGIC, MAGIC, MAGIC };
+ int ret;
- ret = u8_uctomb (buf, uc, 0);
- ASSERT (ret == -2);
- ASSERT (buf[0] == MAGIC);
+ ret = u8_uctomb (buf, uc, 0);
+ ASSERT (ret == -2);
+ ASSERT (buf[0] == MAGIC);
- ret = u8_uctomb (buf, uc, 1);
- ASSERT (ret == 1);
- ASSERT (buf[0] == uc);
- ASSERT (buf[1] == MAGIC);
- }
- }
+ ret = u8_uctomb (buf, uc, 1);
+ ASSERT (ret == 1);
+ ASSERT (buf[0] == uc);
+ ASSERT (buf[1] == MAGIC);
+ }
/* Test 2-byte character. */
{
{
ucs4_t invalid[] = { 0x110000, 0xD800, 0xDBFF, 0xDC00, 0xDFFF };
uint8_t buf[5] = { MAGIC, MAGIC, MAGIC, MAGIC, MAGIC };
- size_t i;
- for (i = 0; i < SIZEOF (invalid); i++)
+ for (size_t i = 0; i < SIZEOF (invalid); i++)
{
ucs4_t uc = invalid[i];
- int n;
- for (n = 0; n <= 4; n++)
+ for (int n = 0; n <= 4; n++)
{
int ret = u8_uctomb (buf, uc, n);
ASSERT (ret == -1);
0x65E5, 0x672C, 0x8A9E, ',', 0x4E2D, 0x6587, ',', 0xD55C, 0xAE00, '\n'
};
char *p = (char *) malloc (SIZEOF (input));
- size_t i;
u16_wordbreaks (input, SIZEOF (input), p);
- for (i = 0; i < 61; i++)
+ for (size_t i = 0; i < 61; i++)
{
ASSERT (p[i] == ((i >= 4 && i <= 5)
|| (i >= 9 && i <= 11)
0x1112, 0x1161, 0x11AB, 0x1100, 0x1173, 0x11AF, '\n'
};
char *p = (char *) malloc (SIZEOF (input));
- size_t i;
u16_wordbreaks (input, SIZEOF (input), p);
- for (i = 0; i < 67; i++)
+ for (size_t i = 0; i < 67; i++)
{
ASSERT (p[i] == ((i >= 5 && i <= 6)
|| (i >= 10 && i <= 12)
static const uint16_t input[8] =
{ 'a', '\n', 'b', '\r', 'c', '\r', '\n', 'd' };
char *p = (char *) malloc (SIZEOF (input));
- size_t i;
u16_wordbreaks (input, SIZEOF (input), p);
- for (i = 0; i < 8; i++)
+ for (size_t i = 0; i < 8; i++)
{
ASSERT (p[i] == (i == 1 || i == 2 || i == 3 || i == 4 || i == 5
|| i == 7 ? 1 :
static const uint16_t input[10] =
{ '.', 0xD83C, 0xDDE9, 0xD83C, 0xDDEA, 0xD83C, 0xDDEB, 0xD83C, 0xDDF7, '.' };
char *p = (char *) malloc (SIZEOF (input));
- size_t i;
u16_wordbreaks (input, SIZEOF (input), p);
- for (i = 0; i < 10; i++)
+ for (size_t i = 0; i < 10; i++)
{
ASSERT (p[i] == (i == 1 || i == 5 || i == 9 ? 1 : 0));
}
0x65E5, 0x672C, 0x8A9E, ',', 0x4E2D, 0x6587, ',', 0xD55C, 0xAE00, '\n'
};
char *p = (char *) malloc (SIZEOF (input));
- size_t i;
u32_wordbreaks (input, SIZEOF (input), p);
- for (i = 0; i < 61; i++)
+ for (size_t i = 0; i < 61; i++)
{
ASSERT (p[i] == ((i >= 4 && i <= 5)
|| (i >= 9 && i <= 11)
0x1112, 0x1161, 0x11AB, 0x1100, 0x1173, 0x11AF, '\n'
};
char *p = (char *) malloc (SIZEOF (input));
- size_t i;
u32_wordbreaks (input, SIZEOF (input), p);
- for (i = 0; i < 67; i++)
+ for (size_t i = 0; i < 67; i++)
{
ASSERT (p[i] == ((i >= 5 && i <= 6)
|| (i >= 10 && i <= 12)
static const uint32_t input[8] =
{ 'a', '\n', 'b', '\r', 'c', '\r', '\n', 'd' };
char *p = (char *) malloc (SIZEOF (input));
- size_t i;
u32_wordbreaks (input, SIZEOF (input), p);
- for (i = 0; i < 8; i++)
+ for (size_t i = 0; i < 8; i++)
{
ASSERT (p[i] == (i == 1 || i == 2 || i == 3 || i == 4 || i == 5
|| i == 7 ? 1 :
static const uint32_t input[6] =
{ '.', 0x1F1E9, 0x1F1EA, 0x1F1EB, 0x1F1F7, '.' };
char *p = (char *) malloc (SIZEOF (input));
- size_t i;
u32_wordbreaks (input, SIZEOF (input), p);
- for (i = 0; i < 6; i++)
+ for (size_t i = 0; i < 6; i++)
{
ASSERT (p[i] == (i == 1 || i == 3 || i == 5 ? 1 : 0));
}
/* "Grüß Gott. Здравствуйте! x=(-b±sqrt(b²-4ac))/(2a) 日本語,中文,한글" */
"Gr\303\274\303\237 Gott. \320\227\320\264\321\200\320\260\320\262\321\201\321\202\320\262\321\203\320\271\321\202\320\265! x=(-b\302\261sqrt(b\302\262-4ac))/(2a) \346\227\245\346\234\254\350\252\236,\344\270\255\346\226\207,\355\225\234\352\270\200\n";
char *p = (char *) malloc (SIZEOF (input));
- size_t i;
u8_wordbreaks (input, SIZEOF (input), p);
- for (i = 0; i < 91; i++)
+ for (size_t i = 0; i < 91; i++)
{
ASSERT (p[i] == ((i >= 6 && i <= 7)
|| (i >= 11 && i <= 13)
/* "Grüß Gott. Здравствуйте! x=(-b±sqrt(b²-4ac))/(2a) 日本語,中文,한글" */
"Gru\314\210\303\237 Gott. \320\227\320\264\321\200\320\260\320\262\321\201\321\202\320\262\321\203\320\270\314\206\321\202\320\265! x=(-b\302\261sqrt(b\302\262-4ac))/(2a) \346\227\245\346\234\254\350\252\236,\344\270\255\346\226\207,\341\204\222\341\205\241\341\206\253\341\204\200\341\205\263\341\206\257\n";
char *p = (char *) malloc (SIZEOF (input));
- size_t i;
u8_wordbreaks (input, SIZEOF (input), p);
- for (i = 0; i < 106; i++)
+ for (size_t i = 0; i < 106; i++)
{
ASSERT (p[i] == ((i >= 7 && i <= 8)
|| (i >= 12 && i <= 14)
{
static const uint8_t input[8] _GL_ATTRIBUTE_NONSTRING = "a\nb\rc\r\nd";
char *p = (char *) malloc (SIZEOF (input));
- size_t i;
u8_wordbreaks (input, SIZEOF (input), p);
- for (i = 0; i < 8; i++)
+ for (size_t i = 0; i < 8; i++)
{
ASSERT (p[i] == (i == 1 || i == 2 || i == 3 || i == 4 || i == 5
|| i == 7 ? 1 :
static const uint8_t input[18] _GL_ATTRIBUTE_NONSTRING =
".\360\237\207\251\360\237\207\252\360\237\207\253\360\237\207\267.";
char *p = (char *) malloc (SIZEOF (input));
- size_t i;
u8_wordbreaks (input, SIZEOF (input), p);
- for (i = 0; i < 18; i++)
+ for (size_t i = 0; i < 18; i++)
{
ASSERT (p[i] == (i == 1 || i == 9 || i == 17 ? 1 : 0));
}
breaks[0] = breaks_expected[0] = 1;
if (memcmp (breaks, breaks_expected, i - 1) != 0)
{
- int j;
-
fprintf (stderr, "%s:%d: expected: ", filename, lineno);
- for (j = 0; j < i - 1; j++)
+ for (int j = 0; j < i - 1; j++)
{
int input_wbp = uc_wordbreak_property (input[j]);
fprintf (stderr, "%s U+%04X (%s) ",
}
fprintf (stderr, "\n");
fprintf (stderr, "%s:%d: actual: ", filename, lineno);
- for (j = 0; j < i - 1; j++)
+ for (int j = 0; j < i - 1; j++)
{
int input_wbp = uc_wordbreak_property (input[j]);
fprintf (stderr, "%s U+%04X (%s) ",
/* "Grüß Gott. x=(-b±sqrt(b²-4ac))/(2a)" */
"Gr\374\337 Gott. x=(-b\261sqrt(b\262-4ac))/(2a)\n";
char *p = (char *) malloc (SIZEOF (input));
- size_t i;
ulc_wordbreaks (input, SIZEOF (input), p);
- for (i = 0; i < 36; i++)
+ for (size_t i = 0; i < 36; i++)
{
ASSERT (p[i] == ((i >= 4 && i <= 5)
|| (i >= 9 && i <= 17)
int
main ()
{
- ucs4_t uc;
-
/* Test width of ASCII characters. */
- for (uc = 0x0020; uc < 0x007F; uc++)
+ for (ucs4_t uc = 0x0020; uc < 0x007F; uc++)
ASSERT (uc_width (uc, "ISO-8859-2") == 1);
/* Test width of some non-spacing characters. */
int
main ()
{
- ucs4_t uc;
-
- for (uc = 0; uc < 0x110000; uc++)
+ for (ucs4_t uc = 0; uc < 0x110000; uc++)
{
int w1 = uc_width (uc, "UTF-8");
int w2 = uc_width (uc, "GBK");
{
buf[n] = '\0';
char *saveptr;
- char *word;
- for (word = strtok_r (buf, " \n", &saveptr);
+ for (char *word = strtok_r (buf, " \n", &saveptr);
word != NULL;
word = strtok_r (NULL, " \n", &saveptr))
{
int n = read (fd, buf, sizeof (buf));
if (n <= 0)
break;
- int i;
- for (i = 0; i < n; i++)
+ for (int i = 0; i < n; i++)
{
if (last_char_was_newline && buf[i] == '\n')
blank_lines++;