summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitry Antipov <dmantipov@yandex.ru>2014-10-03 08:35:10 +0400
committerDmitry Antipov <dmantipov@yandex.ru>2014-10-03 08:35:10 +0400
commit6846b0036a0ff938d93c2d4df0f177dab3e06623 (patch)
tree58d57f74be7d3f7b9f4c01d7380528e6cbe63c30
parent11bd10a7df907289382bd6f06753e274376d7629 (diff)
downloademacs-6846b0036a0ff938d93c2d4df0f177dab3e06623.tar.gz
Consistently use min and max macros from lisp.h.
* coding.c (min, max): * font.c (MAX): * unexhp9k800.c (min): * unexw32.c (min, max): Use definitions from lisp.h. * regex.c (MAX, MIN) [!emacs]: Define own max and min as such. Adjust users. * gmalloc.c (min): Tiny style change.
-rw-r--r--src/ChangeLog11
-rw-r--r--src/coding.c9
-rw-r--r--src/font.c6
-rw-r--r--src/gmalloc.c2
-rw-r--r--src/regex.c24
-rw-r--r--src/unexhp9k800.c1
-rw-r--r--src/unexw32.c5
7 files changed, 26 insertions, 32 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index f5f1d8e0458..6a4ef3a1dd9 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,14 @@
+2014-10-03 Dmitry Antipov <dmantipov@yandex.ru>
+
+ Consistently use min and max macros from lisp.h.
+ * coding.c (min, max):
+ * font.c (MAX):
+ * unexhp9k800.c (min):
+ * unexw32.c (min, max): Use definitions from lisp.h.
+ * regex.c (MAX, MIN) [!emacs]: Define own max and min as such.
+ Adjust users.
+ * gmalloc.c (min): Tiny style change.
+
2014-10-03 Paul Eggert <eggert@cs.ucla.edu>
Fix x-focus-frame bug with "Not an in-range integer" (Bug#18586).
diff --git a/src/coding.c b/src/coding.c
index ed107a297ba..0337c0df60e 100644
--- a/src/coding.c
+++ b/src/coding.c
@@ -642,15 +642,6 @@ static enum coding_category coding_priorities[coding_category_max];
Nth coding category. */
static struct coding_system coding_categories[coding_category_max];
-/*** Commonly used macros and functions ***/
-
-#ifndef min
-#define min(a, b) ((a) < (b) ? (a) : (b))
-#endif
-#ifndef max
-#define max(a, b) ((a) > (b) ? (a) : (b))
-#endif
-
/* Encode a flag that can be nil, something else, or t as -1, 0, 1. */
static int
diff --git a/src/font.c b/src/font.c
index 4d99087ef7d..8405065a0d0 100644
--- a/src/font.c
+++ b/src/font.c
@@ -41,10 +41,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
#include TERM_HEADER
#endif /* HAVE_WINDOW_SYSTEM */
-#ifndef MAX
-# define MAX(a, b) ((a) > (b) ? (a) : (b))
-#endif
-
Lisp_Object Qopentype;
/* Important character set strings. */
@@ -1310,7 +1306,7 @@ font_unparse_xlfd (Lisp_Object font, int pixel_size, char *name, int nbytes)
val = AREF (font, FONT_SIZE_INDEX);
eassert (NUMBERP (val) || NILP (val));
char font_size_index_buf[sizeof "-*"
- + MAX (INT_STRLEN_BOUND (EMACS_INT),
+ + max (INT_STRLEN_BOUND (EMACS_INT),
1 + DBL_MAX_10_EXP + 1)];
if (INTEGERP (val))
{
diff --git a/src/gmalloc.c b/src/gmalloc.c
index 47046cc6747..3456ff0ec6f 100644
--- a/src/gmalloc.c
+++ b/src/gmalloc.c
@@ -1303,7 +1303,7 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
or (US mail) as Mike Haertel c/o Free Software Foundation. */
#ifndef min
-#define min(A, B) ((A) < (B) ? (A) : (B))
+#define min(a, b) ((a) < (b) ? (a) : (b))
#endif
/* Debugging hook for realloc. */
diff --git a/src/regex.c b/src/regex.c
index 9e9018bff88..766ad26e709 100644
--- a/src/regex.c
+++ b/src/regex.c
@@ -515,10 +515,12 @@ init_syntax_once (void)
#define STREQ(s1, s2) ((strcmp (s1, s2) == 0))
-#undef MAX
-#undef MIN
-#define MAX(a, b) ((a) > (b) ? (a) : (b))
-#define MIN(a, b) ((a) < (b) ? (a) : (b))
+#ifndef emacs
+# undef max
+# undef min
+# define max(a, b) ((a) > (b) ? (a) : (b))
+# define min(a, b) ((a) < (b) ? (a) : (b))
+#endif
/* Type of source-pattern and string chars. */
#ifdef _MSC_VER
@@ -1394,14 +1396,14 @@ typedef struct
: ((fail_stack).stack \
= REGEX_REALLOCATE_STACK ((fail_stack).stack, \
(fail_stack).size * sizeof (fail_stack_elt_t), \
- MIN (re_max_failures * TYPICAL_FAILURE_SIZE, \
+ min (re_max_failures * TYPICAL_FAILURE_SIZE, \
((fail_stack).size * sizeof (fail_stack_elt_t) \
* FAIL_STACK_GROWTH_FACTOR))), \
\
(fail_stack).stack == NULL \
? 0 \
: ((fail_stack).size \
- = (MIN (re_max_failures * TYPICAL_FAILURE_SIZE, \
+ = (min (re_max_failures * TYPICAL_FAILURE_SIZE, \
((fail_stack).size * sizeof (fail_stack_elt_t) \
* FAIL_STACK_GROWTH_FACTOR)) \
/ sizeof (fail_stack_elt_t)), \
@@ -2309,8 +2311,8 @@ set_image_of_range (struct range_table_work_area *work_area,
cmin = c, cmax = c;
else
{
- cmin = MIN (cmin, c);
- cmax = MAX (cmax, c);
+ cmin = min (cmin, c);
+ cmax = max (cmax, c);
}
}
}
@@ -2989,7 +2991,7 @@ regex_compile (const_re_char *pattern, size_t size, reg_syntax_t syntax,
#else /* emacs */
if (c < 128)
{
- ch = MIN (127, c1);
+ ch = min (127, c1);
SETUP_ASCII_RANGE (range_table_work, c, ch);
c = ch + 1;
if (CHAR_BYTE8_P (c1))
@@ -5210,7 +5212,7 @@ re_match_2_internal (struct re_pattern_buffer *bufp, const_re_char *string1,
{ /* No. So allocate them with malloc. We need one
extra element beyond `num_regs' for the `-1' marker
GNU code uses. */
- regs->num_regs = MAX (RE_NREGS, num_regs + 1);
+ regs->num_regs = max (RE_NREGS, num_regs + 1);
regs->start = TALLOC (regs->num_regs, regoff_t);
regs->end = TALLOC (regs->num_regs, regoff_t);
if (regs->start == NULL || regs->end == NULL)
@@ -5254,7 +5256,7 @@ re_match_2_internal (struct re_pattern_buffer *bufp, const_re_char *string1,
/* Go through the first `min (num_regs, regs->num_regs)'
registers, since that is all we initialized. */
- for (reg = 1; reg < MIN (num_regs, regs->num_regs); reg++)
+ for (reg = 1; reg < min (num_regs, regs->num_regs); reg++)
{
if (REG_UNSET (regstart[reg]) || REG_UNSET (regend[reg]))
regs->start[reg] = regs->end[reg] = -1;
diff --git a/src/unexhp9k800.c b/src/unexhp9k800.c
index 55db8071b76..cbf1835b9ee 100644
--- a/src/unexhp9k800.c
+++ b/src/unexhp9k800.c
@@ -72,7 +72,6 @@ run_time_remap (char *ignored)
#undef roundup
#define roundup(x,n) (((x) + ((n) - 1)) & ~((n) - 1)) /* n is power of 2 */
-#define min(x,y) (((x) < (y)) ? (x) : (y))
/* Report a fatal error and exit. */
static _Noreturn void
diff --git a/src/unexw32.c b/src/unexw32.c
index 95c805d09ae..5c1c1f3f391 100644
--- a/src/unexw32.c
+++ b/src/unexw32.c
@@ -48,11 +48,6 @@ extern char *my_begbss_static;
#include "w32heap.h"
-#undef min
-#undef max
-#define min(x, y) (((x) < (y)) ? (x) : (y))
-#define max(x, y) (((x) > (y)) ? (x) : (y))
-
/* Basically, our "initialized" flag. */
BOOL using_dynamic_heap = FALSE;