]> granicus.if.org Git - vim/commitdiff
Use UINT32_T in the code, define it to uint32_t or unsigned int.
authorBram Moolenaar <Bram@vim.org>
Wed, 19 May 2010 19:57:45 +0000 (21:57 +0200)
committerBram Moolenaar <Bram@vim.org>
Wed, 19 May 2010 19:57:45 +0000 (21:57 +0200)
Better autoconf check for uint32_t.

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

index 1c4c1980e52efef5296f7c4244fbf01485e12447..11f5748a5c284b86e5177eed016ad5037f1ee85b 100644 (file)
@@ -1366,7 +1366,7 @@ this before writing the file.  When reading an encrypted file it will be set
 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
index 62ecb5af2cca05e090b5955673b62ca615d06228..fcc4f9b87f1d6df7b06f3546f73194b360030bf7 100644 (file)
@@ -31,10 +31,17 @@ be worked on, but only if you sponsor Vim development.  See |sponsor|.
 -------------------- 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)
index 7537e9325d5af168086c07c065aafeb4b4e9a40e..cc7d2a17e285e2cb59ff11aaf6e21cf8c4dc7169 100755 (executable)
@@ -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 @@ _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 @@ _ACEOF
 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"
index ee64db65c9cac338212fa81e83387f8ecbfe4eac..01e09930656ee1f7f26e61d596cdc3c76bb72cf0 100644 (file)
@@ -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++;
index c5f70fc8e02ad2ff1bbd5902690c22b1b9e41fae..c57cd2fa481b632c7c63d62911fc53f0d36343f2 100644 (file)
 #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
 #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
index 72138f78e1b5aa3f581ea9186a3c8db772ffd957..0068d34fa09ff3c7283896910314f284ad371232 100644 (file)
@@ -2174,14 +2174,16 @@ if test $ac_cv_header_sys_wait_h = no; then
                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.
 
index e058f9e8eee897d2bfdf775d31a27a64383424fe..93a9aea75578ddfd55c7fda572cb3520354501dd 100644 (file)
 # 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>
index de3211a92f4484424f88ee969f3468f59fc704e9..9372d5f00fa0ebbd083e482eaa90aaf4a6bbb988 100644 (file)
 #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((void));
 
 #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);
index 60eae8445e318a69005feb630e3d8681324fcad1..d320d3a9520cae8a6592ed0f4ec93f41ebeb1edf 100644 (file)
--- a/src/vim.h
+++ b/src/vim.h
 # 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
 # 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;        /* long should be 32 bits or more */
 
 #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 required for the prototypes. */
 
 #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 required for the prototypes. */
 #  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