Mercurial > vim
changeset 2199:014a996ac896 vim73
Use UINT32_T in the code, define it to uint32_t or unsigned int.
Better autoconf check for uint32_t.
author | Bram Moolenaar <bram@vim.org> |
---|---|
date | Wed, 19 May 2010 21:57:45 +0200 |
parents | e741fe7a0547 |
children | 99ba9a30755a |
files | runtime/doc/editing.txt runtime/doc/todo.txt src/auto/configure src/blowfish.c src/config.h.in src/configure.in src/netbeans.c src/sha256.c src/vim.h |
diffstat | 9 files changed, 146 insertions(+), 75 deletions(-) [+] |
line wrap: on
line diff
--- a/runtime/doc/editing.txt +++ b/runtime/doc/editing.txt @@ -1366,7 +1366,7 @@ this before writing the file. When read automatically to the method used when that file was written. You can change 'cryptmethod' before writing that file to change the method. - *E817* *E818* *E819* + *E817* *E818* *E819* *E820* When encryption does not work properly, you would be able to write your text to a file and never be able to read it back. Therefore a test is performed to check if the encryption works as expected. If you get one of these errors
--- a/runtime/doc/todo.txt +++ b/runtime/doc/todo.txt @@ -31,10 +31,17 @@ be worked on, but only if you sponsor Vi -------------------- Known bugs and current work ----------------------- Crypt update: +- Make sure test71 fails when blowfish test fails. - When not full match with magic, check for head and give warning about unsupported crypt method. - if 'enc' is ucs-2, does utf-8 to ucs-2 encoding always work for seed? +After patch 7.2.407 a backslash before a newline is turned into a NUL. (Andy +Wokula, 2010 May 18) +No longer possible to insert a line break? Roll back the patch? + +"g8" doesn't produce right value on NUL. Patch (Dominique Pelle, 2010 May 18) + Include cabal and obj syntax files. (Vincent Berthoux, 2010 May 16) Cursor positioning wrong with 0x200e character. (John Becket, 2010 May 6)
--- a/src/auto/configure +++ b/src/auto/configure @@ -8649,14 +8649,16 @@ fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi -for ac_header in stdarg.h stdlib.h string.h sys/select.h sys/utsname.h \ - termcap.h fcntl.h sgtty.h sys/ioctl.h sys/time.h sys/types.h termio.h \ - iconv.h langinfo.h math.h unistd.h stropts.h errno.h \ - sys/resource.h sys/systeminfo.h locale.h \ - sys/stream.h termios.h libc.h sys/statfs.h \ - poll.h sys/poll.h pwd.h utime.h sys/param.h libintl.h \ - libgen.h util/debug.h util/msg18n.h frame.h \ - sys/acl.h sys/access.h sys/sysinfo.h wchar.h wctype.h +for ac_header in stdarg.h stdint.h stdlib.h string.h \ + sys/select.h sys/utsname.h termcap.h fcntl.h \ + sgtty.h sys/ioctl.h sys/time.h sys/types.h \ + termio.h iconv.h inttypes.h langinfo.h math.h \ + unistd.h stropts.h errno.h sys/resource.h \ + sys/systeminfo.h locale.h sys/stream.h termios.h \ + libc.h sys/statfs.h poll.h sys/poll.h pwd.h \ + utime.h sys/param.h libintl.h libgen.h \ + util/debug.h util/msg18n.h frame.h sys/acl.h \ + sys/access.h sys/sysinfo.h wchar.h wctype.h do : as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default" @@ -9033,6 +9035,7 @@ cat >>confdefs.h <<_ACEOF ;; esac + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether time.h and sys/time.h may both be included" >&5 $as_echo_n "checking whether time.h and sys/time.h may both be included... " >&6; } if test "${ac_cv_header_time+set}" = set; then : @@ -11216,7 +11219,7 @@ main() if ac_fn_c_try_run "$LINENO"; then : ac_cv_sizeof_int=`cat conftestval` else - ac_cv_sizeof_int=0 + as_fn_error "failed to determine sizeof(int)" "$LINENO" 5 fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext @@ -11231,6 +11234,38 @@ cat >>confdefs.h <<_ACEOF _ACEOF +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking uint32_t is 32 bits" >&5 +$as_echo_n "checking uint32_t is 32 bits... " >&6; } +if test "$cross_compiling" = yes; then : + as_fn_error "could not compile program using uint32_t." "$LINENO" 5 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +#ifdef HAVE_STDINT_H +# include <stdint.h> +#endif +#ifdef HAVE_INTTYPES_H +# include <inttypes.h> +#endif +main() { + uint32_t nr1 = (uint32_t)-1; + uint32_t nr2 = (uint32_t)0xffffffffUL; + if (sizeof(uint32_t) != 4 || nr1 != 0xffffffffUL || nr2 + 1 != 0) exit(1); + exit(0); +} +_ACEOF +if ac_fn_c_try_run "$LINENO"; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: result: ok" >&5 +$as_echo "ok" >&6; } +else + as_fn_error "WRONG! uint32_t not defined correctly." "$LINENO" 5 +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ + conftest.$ac_objext conftest.beam conftest.$ac_ext +fi + + bcopy_test_prog=' #include "confdefs.h"
--- a/src/blowfish.c +++ b/src/blowfish.c @@ -21,7 +21,7 @@ #define BF_OFB_LEN (8*(BF_BLOCK)) typedef union { - uint32_t ul[2]; + UINT32_T ul[2]; char_u uc[8]; } block8; @@ -36,14 +36,14 @@ typedef union { # endif #endif -static void bf_e_block __ARGS((uint32_t *p_xl, uint32_t *p_xr)); +static void bf_e_block __ARGS((UINT32_T *p_xl, UINT32_T *p_xr)); static void bf_e_cblock __ARGS((char_u *block)); -static int bf_check_tables __ARGS((uint32_t ipa[18], uint32_t sbi[4][256], uint32_t val)); +static int bf_check_tables __ARGS((UINT32_T ipa[18], UINT32_T sbi[4][256], UINT32_T val)); static int bf_self_test __ARGS((void)); /* Blowfish code */ -static uint32_t pax[18]; -static uint32_t ipa[18] = { +static UINT32_T pax[18]; +static UINT32_T ipa[18] = { 0x243f6a88u, 0x85a308d3u, 0x13198a2eu, 0x03707344u, 0xa4093822u, 0x299f31d0u, 0x082efa98u, 0xec4e6c89u, 0x452821e6u, @@ -52,8 +52,8 @@ static uint32_t ipa[18] = { 0xb5470917u, 0x9216d5d9u, 0x8979fb1bu }; -static uint32_t sbx[4][256]; -static uint32_t sbi[4][256] = { +static UINT32_T sbx[4][256]; +static UINT32_T sbi[4][256] = { {0xd1310ba6u, 0x98dfb5acu, 0x2ffd72dbu, 0xd01adfb7u, 0xb8e1afedu, 0x6a267e96u, 0xba7c9045u, 0xf12c7f99u, 0x24a19947u, 0xb3916cf7u, 0x0801f2e2u, 0x858efc16u, @@ -331,10 +331,10 @@ static uint32_t sbi[4][256] = { static void bf_e_block(p_xl, p_xr) - uint32_t *p_xl; - uint32_t *p_xr; + UINT32_T *p_xl; + UINT32_T *p_xr; { - uint32_t temp, xl = *p_xl, xr = *p_xr; + UINT32_T temp, xl = *p_xl, xr = *p_xr; F1(0) F2(1) F1(2) F2(3) F1(4) F2(5) F1(6) F2(7) F1(8) F2(9) F1(10) F2(11) F1(12) F2(13) F1(14) F2(15) @@ -346,10 +346,10 @@ bf_e_block(p_xl, p_xr) #if 0 /* not used */ static void bf_d_block(p_xl, p_xr) - uint32_t *p_xl; - uint32_t *p_xr; + UINT32_T *p_xl; + UINT32_T *p_xr; { - uint32_t temp, xl = *p_xl, xr = *p_xr; + UINT32_T temp, xl = *p_xl, xr = *p_xr; F1(17) F2(16) F1(15) F2(14) F1(13) F2(12) F1(11) F2(10) F1(9) F2(8) F1(7) F2(6) F1(5) F2(4) F1(3) F2(2) xl ^= pax[1]; @@ -401,7 +401,7 @@ bf_key_init(password) char_u *password; { int i, j, keypos = 0; - uint32_t val, data_l, data_r; + UINT32_T val, data_l, data_r; char_u *key; int keylen; @@ -447,12 +447,12 @@ bf_key_init(password) */ static int bf_check_tables(ipa, sbi, val) - uint32_t ipa[18]; - uint32_t sbi[4][256]; - uint32_t val; + UINT32_T ipa[18]; + UINT32_T sbi[4][256]; + UINT32_T val; { int i, j; - uint32_t c = 0; + UINT32_T c = 0; for (i = 0; i < 18; i++) c ^= ipa[i]; @@ -467,7 +467,7 @@ typedef struct { char_u plaintxt[8]; char_u cryptxt[8]; char_u badcryptxt[8]; /* cryptxt when big/little endian is wrong */ - uint32_t keysum; + UINT32_T keysum; } struct_bf_test_data; /* @@ -493,6 +493,14 @@ bf_self_test() int i, bn; int err = 0; block8 bk; + UINT32_T ui = 0xffffffffUL; + + /* We can't simply use sizeof(UINT32_T), it would generate a compiler + * warning. */ + if (ui != 0xffffffffUL || ui + 1 != 0) { + err++; + EMSG(_("E820: sizeof(uint32_t) != 4")); + } if (!bf_check_tables(ipa, sbi, 0x6ffa520a)) err++;
--- a/src/config.h.in +++ b/src/config.h.in @@ -216,6 +216,7 @@ #undef HAVE_FCNTL_H #undef HAVE_FRAME_H #undef HAVE_ICONV_H +#undef HAVE_INTTYPES_H #undef HAVE_LANGINFO_H #undef HAVE_LIBC_H #undef HAVE_LIBGEN_H @@ -228,6 +229,7 @@ #undef HAVE_PWD_H #undef HAVE_SETJMP_H #undef HAVE_SGTTY_H +#undef HAVE_STDINT_H #undef HAVE_STRINGS_H #undef HAVE_STROPTS_H #undef HAVE_SYS_ACCESS_H
--- a/src/configure.in +++ b/src/configure.in @@ -2174,14 +2174,16 @@ if test $ac_cv_header_sys_wait_h = no; t AC_MSG_RESULT(no)) fi -AC_CHECK_HEADERS(stdarg.h stdlib.h string.h sys/select.h sys/utsname.h \ - termcap.h fcntl.h sgtty.h sys/ioctl.h sys/time.h sys/types.h termio.h \ - iconv.h langinfo.h math.h unistd.h stropts.h errno.h \ - sys/resource.h sys/systeminfo.h locale.h \ - sys/stream.h termios.h libc.h sys/statfs.h \ - poll.h sys/poll.h pwd.h utime.h sys/param.h libintl.h \ - libgen.h util/debug.h util/msg18n.h frame.h \ - sys/acl.h sys/access.h sys/sysinfo.h wchar.h wctype.h) +AC_CHECK_HEADERS(stdarg.h stdint.h stdlib.h string.h \ + sys/select.h sys/utsname.h termcap.h fcntl.h \ + sgtty.h sys/ioctl.h sys/time.h sys/types.h \ + termio.h iconv.h inttypes.h langinfo.h math.h \ + unistd.h stropts.h errno.h sys/resource.h \ + sys/systeminfo.h locale.h sys/stream.h termios.h \ + libc.h sys/statfs.h poll.h sys/poll.h pwd.h \ + utime.h sys/param.h libintl.h libgen.h \ + util/debug.h util/msg18n.h frame.h sys/acl.h \ + sys/access.h sys/sysinfo.h wchar.h wctype.h) dnl sys/ptem.h depends on sys/stream.h on Solaris AC_CHECK_HEADERS(sys/ptem.h, [], [], @@ -2247,6 +2249,7 @@ AC_TYPE_PID_T AC_TYPE_SIZE_T AC_TYPE_UID_T AC_TYPE_UINT32_T + AC_HEADER_TIME AC_CHECK_TYPE(ino_t, long) AC_CHECK_TYPE(dev_t, unsigned) @@ -2975,11 +2978,30 @@ main() exit(0); }], ac_cv_sizeof_int=`cat conftestval`, - ac_cv_sizeof_int=0, - AC_MSG_ERROR(failed to compile test program))]) + AC_MSG_ERROR([failed to determine sizeof(int)]), + AC_MSG_ERROR([failed to compile test program]))]) AC_MSG_RESULT($ac_cv_sizeof_int) AC_DEFINE_UNQUOTED(SIZEOF_INT, $ac_cv_sizeof_int) +dnl Make sure that uint32_t is really 32 bits unsigned. +AC_MSG_CHECKING([uint32_t is 32 bits]) +AC_TRY_RUN([ +#ifdef HAVE_STDINT_H +# include <stdint.h> +#endif +#ifdef HAVE_INTTYPES_H +# include <inttypes.h> +#endif +main() { + uint32_t nr1 = (uint32_t)-1; + uint32_t nr2 = (uint32_t)0xffffffffUL; + if (sizeof(uint32_t) != 4 || nr1 != 0xffffffffUL || nr2 + 1 != 0) exit(1); + exit(0); +}], +AC_MSG_RESULT(ok), +AC_MSG_ERROR([WRONG! uint32_t not defined correctly.]), +AC_MSG_ERROR([could not compile program using uint32_t.])) + dnl Check for memmove() before bcopy(), makes memmove() be used when both are dnl present, fixes problem with incompatibility between Solaris 2.4 and 2.5.
--- a/src/netbeans.c +++ b/src/netbeans.c @@ -43,12 +43,6 @@ # define sock_close(sd) closesocket(sd) # define sleep(t) Sleep(t*1000) /* WinAPI Sleep() accepts milliseconds */ #else - /* uint32_t may be defined by configure, but netdb.h indirectly includes - * stdint.h which tries to typedef uint32_t and fails. */ -# ifdef uint32_t -# undef uint32_t -# undef __uint32_t_defined -# endif # include <netdb.h> # include <netinet/in.h> # include <sys/socket.h>
--- a/src/sha256.c +++ b/src/sha256.c @@ -23,14 +23,14 @@ #ifdef FEAT_CRYPT typedef struct { - uint32_t total[2]; - uint32_t state[8]; + UINT32_T total[2]; + UINT32_T state[8]; char_u buffer[64]; } context_sha256_T; static void sha256_starts __ARGS((context_sha256_T *ctx)); static void sha256_process __ARGS((context_sha256_T *ctx, char_u data[64])); -static void sha256_update __ARGS((context_sha256_T *ctx, char_u *input, uint32_t length)); +static void sha256_update __ARGS((context_sha256_T *ctx, char_u *input, UINT32_T length)); static void sha256_finish __ARGS((context_sha256_T *ctx, char_u digest[32])); static char_u *sha256_bytes __ARGS((char_u *buf, int buflen)); static unsigned int get_some_time __ARGS((void)); @@ -38,10 +38,10 @@ static unsigned int get_some_time __ARGS #define GET_UINT32(n, b, i) \ { \ - (n) = ( (uint32_t)(b)[(i) ] << 24) \ - | ( (uint32_t)(b)[(i) + 1] << 16) \ - | ( (uint32_t)(b)[(i) + 2] << 8) \ - | ( (uint32_t)(b)[(i) + 3] ); \ + (n) = ( (UINT32_T)(b)[(i) ] << 24) \ + | ( (UINT32_T)(b)[(i) + 1] << 16) \ + | ( (UINT32_T)(b)[(i) + 2] << 8) \ + | ( (UINT32_T)(b)[(i) + 3] ); \ } #define PUT_UINT32(n,b,i) \ @@ -74,8 +74,8 @@ sha256_process(ctx, data) context_sha256_T *ctx; char_u data[64]; { - uint32_t temp1, temp2, W[64]; - uint32_t A, B, C, D, E, F, G, H; + UINT32_T temp1, temp2, W[64]; + UINT32_T A, B, C, D, E, F, G, H; GET_UINT32(W[0], data, 0); GET_UINT32(W[1], data, 4); @@ -207,9 +207,9 @@ sha256_process(ctx, data) sha256_update(ctx, input, length) context_sha256_T *ctx; char_u *input; - uint32_t length; + UINT32_T length; { - uint32_t left, fill; + UINT32_T left, fill; if (length == 0) return; @@ -255,8 +255,8 @@ sha256_finish(ctx, digest) context_sha256_T *ctx; char_u digest[32]; { - uint32_t last, padn; - uint32_t high, low; + UINT32_T last, padn; + UINT32_T high, low; char_u msglen[8]; high = (ctx->total[0] >> 29) | (ctx->total[1] << 3);
--- a/src/vim.h +++ b/src/vim.h @@ -32,10 +32,6 @@ # include "auto/config.h" # define HAVE_PATHDEF -/* Avoid a problem when stdint.h gets included later, autoconf defines - * uint32_t when it is not typedef'ed. */ -# define __uint32_t_defined - /* * Check if configure correctly managed to find sizeof(int). If this failed, * it becomes zero. This is likely a problem of not being able to run the @@ -52,6 +48,20 @@ # if defined(__CYGWIN32__) && defined(HAVE_FCHDIR) # undef HAVE_FCHDIR # endif + +/* We may need to define the uint32_t on non-Unix system, but using the same + * identifier causes conflicts. Therefore use UINT32_T. */ +# define UINT32_T uint32_t +#endif + +#if !defined(UINT32_T) +# if defined(uint32_t) /* this doesn't catch typedefs, unfortunately */ +# define UINT32_T uint32_t +# else + /* Fall back to assuming unsigned int is 32 bit. If this is wrong then the + * test in blowfish.c will fail. */ +# define UINT32_T unsigned int +# endif #endif /* user ID of root is usually zero, but not for everybody */ @@ -474,6 +484,12 @@ typedef unsigned long u8char_T; /* l #include <assert.h> +#ifdef HAVE_STDINT_H +# include <stdint.h> +#endif +#ifdef HAVE_INTTYPES_H +# include <inttypes.h> +#endif #ifdef HAVE_WCTYPE_H # include <wctype.h> #endif @@ -1984,12 +2000,6 @@ typedef int VimClipboard; /* This is req #endif -#if !defined(HAVE_CONFIG_H) && !defined(uint32_t) \ - && (defined(__CYGWIN32__) || defined(__MINGW32__)) - /* Assuming that MingW and Cygwin do not typedef uint32_t. */ -# define uint32_t unsigned int -#endif - /* ISSYMLINK(mode) tests if a file is a symbolic link. */ #if (defined(S_IFMT) && defined(S_IFLNK)) || defined(S_ISLNK) # define HAVE_ISSYMLINK @@ -2075,13 +2085,6 @@ typedef int VimClipboard; /* This is req # undef bool # endif -/* uint32_t may be defined by configure, but perh.h may indirectly include - * stdint.h which tries to typedef uint32_t and fails. */ -# ifdef uint32_t -# undef uint32_t -# undef __uint32_t_defined -# endif - # ifdef __BORLANDC__ /* Borland has the structure stati64 but not _stati64 */ # define _stati64 stati64