Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/bin/ed Unifdef compatibility for broken realloc.



details:   https://anonhg.NetBSD.org/src/rev/677122efaa80
branches:  trunk
changeset: 447216:677122efaa80
user:      maya <maya%NetBSD.org@localhost>
date:      Fri Jan 04 19:13:58 2019 +0000

description:
Unifdef compatibility for broken realloc.

No binary change

diffstat:

 bin/ed/README |   3 +--
 bin/ed/ed.h   |  30 +-----------------------------
 bin/ed/glbl.c |  30 ++++++++----------------------
 bin/ed/undo.c |  12 ++----------
 4 files changed, 12 insertions(+), 63 deletions(-)

diffs (153 lines):

diff -r 3e22d4a71096 -r 677122efaa80 bin/ed/README
--- a/bin/ed/README     Fri Jan 04 18:51:23 2019 +0000
+++ b/bin/ed/README     Fri Jan 04 19:13:58 2019 +0000
@@ -1,4 +1,4 @@
-$NetBSD: README,v 1.9 1995/03/21 09:04:33 cgd Exp $
+$NetBSD: README,v 1.10 2019/01/04 19:13:58 maya Exp $
 
 ed is an 8-bit-clean, POSIX-compliant line editor.  It should work with
 any regular expression package that conforms to the POSIX interface
@@ -10,7 +10,6 @@
 
 The following compiler directives are recognized:
 DES            - to add encryption support (requires crypt(3))
-NO_REALLOC_NULL        - if realloc(3) does not accept a NULL pointer
 BACKWARDS      - for backwards compatibility
 NEED_INSQUE    - if insque(3) is missing
 
diff -r 3e22d4a71096 -r 677122efaa80 bin/ed/ed.h
--- a/bin/ed/ed.h       Fri Jan 04 18:51:23 2019 +0000
+++ b/bin/ed/ed.h       Fri Jan 04 19:13:58 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ed.h,v 1.37 2014/03/25 17:23:37 joerg Exp $    */
+/*     $NetBSD: ed.h,v 1.38 2019/01/04 19:13:58 maya Exp $     */
 
 /* ed.h: type and constant definitions for the ed editor. */
 /*
@@ -121,33 +121,6 @@
        } \
 }
 
-#if defined(sun) || defined(NO_REALLOC_NULL)
-/* REALLOC: assure at least a minimum size for buffer b */
-#define REALLOC(b,n,i,err) \
-if ((i) > (n)) { \
-       int ti = (n); \
-       char *ts; \
-       SPL1(); \
-       if ((b) != NULL) { \
-               if ((ts = (char *) realloc((b), ti += max((i), MINBUFSZ))) == NULL) { \
-                       fprintf(stderr, "%s\n", strerror(errno)); \
-                       seterrmsg("out of memory"); \
-                       SPL0(); \
-                       return err; \
-               } \
-       } else { \
-               if ((ts = (char *) malloc(ti += max((i), MINBUFSZ))) == NULL) { \
-                       fprintf(stderr, "%s\n", strerror(errno)); \
-                       seterrmsg("out of memory"); \
-                       SPL0(); \
-                       return err; \
-               } \
-       } \
-       (n) = ti; \
-       (b) = ts; \
-       SPL0(); \
-}
-#else /* NO_REALLOC_NULL */
 /* REALLOC: assure at least a minimum size for buffer b */
 #define REALLOC(b,n,i,err) \
 if ((i) > (n)) { \
@@ -164,7 +137,6 @@
        (b) = ts; \
        SPL0(); \
 }
-#endif /* NO_REALLOC_NULL */
 
 /* REQUE: link pred before succ */
 #define REQUE(pred, succ) (pred)->q_forw = (succ), (succ)->q_back = (pred)
diff -r 3e22d4a71096 -r 677122efaa80 bin/ed/glbl.c
--- a/bin/ed/glbl.c     Fri Jan 04 18:51:23 2019 +0000
+++ b/bin/ed/glbl.c     Fri Jan 04 19:13:58 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: glbl.c,v 1.9 2015/08/28 11:29:48 joerg Exp $   */
+/*     $NetBSD: glbl.c,v 1.10 2019/01/04 19:13:58 maya Exp $   */
 
 /* glob.c: This file contains the global command routines for the ed line
    editor */
@@ -33,7 +33,7 @@
 #if 0
 static char *rcsid = "@(#)glob.c,v 1.1 1994/02/01 00:34:40 alm Exp";
 #else
-__RCSID("$NetBSD: glbl.c,v 1.9 2015/08/28 11:29:48 joerg Exp $");
+__RCSID("$NetBSD: glbl.c,v 1.10 2019/01/04 19:13:58 maya Exp $");
 #endif
 #endif /* not lint */
 
@@ -158,27 +158,13 @@
                int ti = active_size;
                line_t **ts;
                SPL1();
-#if defined(sun) || defined(NO_REALLOC_NULL)
-               if (active_list != NULL) {
-#endif
-                       if ((ts = (line_t **) realloc(active_list, 
-                           (ti += MINBUFSZ) * sizeof(line_t **))) == NULL) {
-                               fprintf(stderr, "%s\n", strerror(errno));
-                               seterrmsg("out of memory");
-                               SPL0();
-                               return ERR;
-                       }
-#if defined(sun) || defined(NO_REALLOC_NULL)
-               } else {
-                       if ((ts = (line_t **) malloc((ti += MINBUFSZ) * 
-                           sizeof(line_t **))) == NULL) {
-                               fprintf(stderr, "%s\n", strerror(errno));
-                               seterrmsg("out of memory");
-                               SPL0();
-                               return ERR;
-                       }
+               if ((ts = (line_t **) realloc(active_list, 
+                   (ti += MINBUFSZ) * sizeof(line_t **))) == NULL) {
+                       fprintf(stderr, "%s\n", strerror(errno));
+                       seterrmsg("out of memory");
+                       SPL0();
+                       return ERR;
                }
-#endif
                active_size = ti;
                active_list = ts;
                SPL0();
diff -r 3e22d4a71096 -r 677122efaa80 bin/ed/undo.c
--- a/bin/ed/undo.c     Fri Jan 04 18:51:23 2019 +0000
+++ b/bin/ed/undo.c     Fri Jan 04 19:13:58 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: undo.c,v 1.6 2014/03/23 05:06:42 dholland Exp $        */
+/*     $NetBSD: undo.c,v 1.7 2019/01/04 19:13:58 maya Exp $    */
 
 /* undo.c: This file contains the undo routines for the ed line editor */
 /*-
@@ -32,7 +32,7 @@
 #if 0
 static char *rcsid = "@(#)undo.c,v 1.1 1994/02/01 00:34:44 alm Exp";
 #else
-__RCSID("$NetBSD: undo.c,v 1.6 2014/03/23 05:06:42 dholland Exp $");
+__RCSID("$NetBSD: undo.c,v 1.7 2019/01/04 19:13:58 maya Exp $");
 #endif
 #endif /* not lint */
 
@@ -50,14 +50,6 @@
 {
        undo_t *t;
 
-#if defined(sun) || defined(NO_REALLOC_NULL)
-       if (ustack == NULL &&
-           (ustack = (undo_t *) malloc((usize = USIZE) * sizeof(undo_t))) == NULL) {
-               fprintf(stderr, "%s\n", strerror(errno));
-               seterrmsg("out of memory");
-               return NULL;
-       }
-#endif
        t = ustack;
        if (u_p < usize ||
            (t = (undo_t *) realloc(ustack, (usize += USIZE) * sizeof(undo_t))) != NULL) {



Home | Main Index | Thread Index | Old Index