From: Paul Eggert Date: Fri, 3 Jan 2014 06:47:27 +0000 (-0800) Subject: Port to C89. X-Git-Tag: emacs-24.3.90~173^2^2~42^2~45^2~387^2~83 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=56a0e35287e6931759c40c581cc715d9cbb78409;p=emacs.git Port to C89. * data.c (arithcompare_driver): * fileio.c (Fcar_less_than_car): * fns.c (internal_equal): * frame.c (delete_frame): * lisp.h (enum More_Lisp_Bits): * lread.c (read1): Avoid C99 constructs that don't work in C89. * data.c (ULL_MAX, count_trailing_zeros_ll): New macros, to port to C89, which doesn't have 'long long'. (count_trailing_zero_bits): Use them. --- diff --git a/src/ChangeLog b/src/ChangeLog index 1f68372f31a..0a4bd05bc06 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,17 @@ +2014-01-03 Paul Eggert + + Port to C89. + * data.c (arithcompare_driver): + * fileio.c (Fcar_less_than_car): + * fns.c (internal_equal): + * frame.c (delete_frame): + * lisp.h (enum More_Lisp_Bits): + * lread.c (read1): + Avoid C99 constructs that don't work in C89. + * data.c (ULL_MAX, count_trailing_zeros_ll): New macros, + to port to C89, which doesn't have 'long long'. + (count_trailing_zero_bits): Use them. + 2014-01-03 Chong Yidong * doc.c (Fdocumentation): Remove dynamic-docstring-function. diff --git a/src/data.c b/src/data.c index 10126775e79..1741f908396 100644 --- a/src/data.c +++ b/src/data.c @@ -2320,7 +2320,8 @@ static Lisp_Object arithcompare_driver (ptrdiff_t nargs, Lisp_Object *args, enum Arith_Comparison comparison) { - for (ptrdiff_t argnum = 1; argnum < nargs; ++argnum) + ptrdiff_t argnum; + for (argnum = 1; argnum < nargs; ++argnum) { if (EQ (Qnil, arithcompare (args[argnum-1], args[argnum], comparison))) return Qnil; @@ -2979,10 +2980,12 @@ bool_vector_spare_mask (EMACS_INT nr_bits) #if HAVE_UNSIGNED_LONG_LONG_INT enum { BITS_PER_ULL = CHAR_BIT * sizeof (unsigned long long) }; +# define ULL_MAX ULLONG_MAX #else enum { BITS_PER_ULL = CHAR_BIT * sizeof (unsigned long) }; -# define ULLONG_MAX ULONG_MAX +# define ULL_MAX ULONG_MAX # define count_one_bits_ll count_one_bits_l +# define count_trailing_zeros_ll count_trailing_zeros_l #endif /* Shift VAL right by the width of an unsigned long long. @@ -3140,7 +3143,7 @@ count_trailing_zero_bits (bits_word val) return count_trailing_zeros (val); if (BITS_WORD_MAX == ULONG_MAX) return count_trailing_zeros_l (val); - if (BITS_WORD_MAX == ULLONG_MAX) + if (BITS_WORD_MAX == ULL_MAX) return count_trailing_zeros_ll (val); /* The rest of this code is for the unlikely platform where bits_word differs @@ -3157,7 +3160,7 @@ count_trailing_zero_bits (bits_word val) count < BITS_PER_BITS_WORD - BITS_PER_ULL; count += BITS_PER_ULL) { - if (val & ULLONG_MAX) + if (val & ULL_MAX) return count + count_trailing_zeros_ll (val); val = shift_right_ull (val); } diff --git a/src/fileio.c b/src/fileio.c index 5d8f3cb64f5..d03a2bcf02f 100644 --- a/src/fileio.c +++ b/src/fileio.c @@ -5053,7 +5053,9 @@ DEFUN ("car-less-than-car", Fcar_less_than_car, Scar_less_than_car, 2, 2, 0, doc: /* Return t if (car A) is numerically less than (car B). */) (Lisp_Object a, Lisp_Object b) { - Lisp_Object args[2] = { Fcar (a), Fcar (b), }; + Lisp_Object args[2]; + args[0] = Fcar (a); + args[1] = Fcar (b); return Flss (2, args); } diff --git a/src/fns.c b/src/fns.c index 4c082aa84e2..bc5331358a4 100644 --- a/src/fns.c +++ b/src/fns.c @@ -1996,7 +1996,9 @@ internal_equal (Lisp_Object o1, Lisp_Object o2, int depth, bool props, error ("Stack overflow in equal"); if (NILP (ht)) { - Lisp_Object args[2] = { QCtest, Qeq }; + Lisp_Object args[2]; + args[0] = QCtest; + args[1] = Qeq; ht = Fmake_hash_table (2, args); } switch (XTYPE (o1)) diff --git a/src/frame.c b/src/frame.c index 6024c0c5be5..76883820672 100644 --- a/src/frame.c +++ b/src/frame.c @@ -1372,10 +1372,11 @@ delete_frame (Lisp_Object frame, Lisp_Object force) { + struct terminal *terminal; block_input (); if (FRAME_TERMINAL (f)->delete_frame_hook) (*FRAME_TERMINAL (f)->delete_frame_hook) (f); - struct terminal *terminal = FRAME_TERMINAL (f); + terminal = FRAME_TERMINAL (f); f->output_data.nothing = 0; f->terminal = 0; /* Now the frame is dead. */ unblock_input (); diff --git a/src/lisp.h b/src/lisp.h index 043e5b13f6b..a7e80a41c28 100644 --- a/src/lisp.h +++ b/src/lisp.h @@ -633,7 +633,7 @@ enum More_Lisp_Bits /* Used to extract pseudovector subtype information. */ PSEUDOVECTOR_AREA_BITS = PSEUDOVECTOR_SIZE_BITS + PSEUDOVECTOR_REST_BITS, - PVEC_TYPE_MASK = 0x3f << PSEUDOVECTOR_AREA_BITS, + PVEC_TYPE_MASK = 0x3f << PSEUDOVECTOR_AREA_BITS }; /* These functions extract various sorts of values from a Lisp_Object. diff --git a/src/lread.c b/src/lread.c index d8d826e8e1d..dcc883b2445 100644 --- a/src/lread.c +++ b/src/lread.c @@ -2654,9 +2654,10 @@ read1 (Lisp_Object readcharfun, int *pch, bool first_in_list) /* Accept compiled functions at read-time so that we don't have to build them using function calls. */ Lisp_Object tmp; + struct Lisp_Vector *vec; tmp = read_vector (readcharfun, 1); - struct Lisp_Vector* vec = XVECTOR (tmp); - if (vec->header.size==0) + vec = XVECTOR (tmp); + if (vec->header.size == 0) invalid_syntax ("Empty byte-code object"); make_byte_code (vec); return tmp;