components/tcsh/patches/001.gethost.c.patch
author Lukas Rovensky <Lukas.Rovensky@oracle.com>
Thu, 26 Nov 2015 08:04:44 -0800
branchs11u3-sru
changeset 5139 efbc4023ba66
parent 2494 c2dd5561bf4f
permissions -rw-r--r--
22124201 TCSH Latest Patch 126630-03 changes the behavior of Exit . You cannot exit .
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2494
c2dd5561bf4f 15949286 update tcsh to 6.18.01
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents:
diff changeset
     1
RCS file: /p/tcsh/cvsroot/tcsh/gethost.c,v
c2dd5561bf4f 15949286 update tcsh to 6.18.01
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents:
diff changeset
     2
retrieving revision 1.15
c2dd5561bf4f 15949286 update tcsh to 6.18.01
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents:
diff changeset
     3
diff -u -u -r1.15 gethost.c
c2dd5561bf4f 15949286 update tcsh to 6.18.01
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents:
diff changeset
     4
--- tcsh-6.18.01/gethost.c.orig	15 Jan 2012 17:14:54 -0000	1.15
c2dd5561bf4f 15949286 update tcsh to 6.18.01
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents:
diff changeset
     5
+++ tcsh-6.18.01/gethost.c	4 Jan 2013 22:20:19 -0000
c2dd5561bf4f 15949286 update tcsh to 6.18.01
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents:
diff changeset
     6
@@ -150,11 +150,17 @@
c2dd5561bf4f 15949286 update tcsh to 6.18.01
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents:
diff changeset
     7
 	char *r;
c2dd5561bf4f 15949286 update tcsh to 6.18.01
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents:
diff changeset
     8
 
c2dd5561bf4f 15949286 update tcsh to 6.18.01
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents:
diff changeset
     9
 	if (len == 0)
c2dd5561bf4f 15949286 update tcsh to 6.18.01
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents:
diff changeset
    10
-		len = strlen(b);
c2dd5561bf4f 15949286 update tcsh to 6.18.01
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents:
diff changeset
    11
-	l = strlen(a) + len + 1;
c2dd5561bf4f 15949286 update tcsh to 6.18.01
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents:
diff changeset
    12
+		len = strlen(b) + 1;
c2dd5561bf4f 15949286 update tcsh to 6.18.01
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents:
diff changeset
    13
+	if (a)
c2dd5561bf4f 15949286 update tcsh to 6.18.01
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents:
diff changeset
    14
+	    l = strlen(a) + len;
c2dd5561bf4f 15949286 update tcsh to 6.18.01
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents:
diff changeset
    15
+	else
c2dd5561bf4f 15949286 update tcsh to 6.18.01
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents:
diff changeset
    16
+	    l = len;
c2dd5561bf4f 15949286 update tcsh to 6.18.01
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents:
diff changeset
    17
 	if ((r = malloc(l)) == NULL)
c2dd5561bf4f 15949286 update tcsh to 6.18.01
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents:
diff changeset
    18
 		abort();
c2dd5561bf4f 15949286 update tcsh to 6.18.01
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents:
diff changeset
    19
-	snprintf(r, l, "%s%.*s", a, (int)len, b);
c2dd5561bf4f 15949286 update tcsh to 6.18.01
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents:
diff changeset
    20
+	if (a)
c2dd5561bf4f 15949286 update tcsh to 6.18.01
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents:
diff changeset
    21
+	    snprintf(r, l, "%s%.*s", a, (int)len, b);
c2dd5561bf4f 15949286 update tcsh to 6.18.01
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents:
diff changeset
    22
+	else
c2dd5561bf4f 15949286 update tcsh to 6.18.01
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents:
diff changeset
    23
+	    snprintf(r, l, "%.*s", (int)len, b);
c2dd5561bf4f 15949286 update tcsh to 6.18.01
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents:
diff changeset
    24
 	return r;
c2dd5561bf4f 15949286 update tcsh to 6.18.01
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents:
diff changeset
    25
 }
c2dd5561bf4f 15949286 update tcsh to 6.18.01
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents:
diff changeset
    26
 
c2dd5561bf4f 15949286 update tcsh to 6.18.01
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents:
diff changeset
    27
@@ -171,13 +177,15 @@
c2dd5561bf4f 15949286 update tcsh to 6.18.01
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents:
diff changeset
    28
 		return defs;
c2dd5561bf4f 15949286 update tcsh to 6.18.01
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents:
diff changeset
    29
 
c2dd5561bf4f 15949286 update tcsh to 6.18.01
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents:
diff changeset
    30
 	free(buf);
c2dd5561bf4f 15949286 update tcsh to 6.18.01
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents:
diff changeset
    31
-	buf = strdup("("); /* ) */
c2dd5561bf4f 15949286 update tcsh to 6.18.01
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents:
diff changeset
    32
+	buf = NULL;
c2dd5561bf4f 15949286 update tcsh to 6.18.01
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents:
diff changeset
    33
 	for (ptr = defs; (bptr = strstr(ptr, def)) != NULL; ptr = eptr + 1) {
c2dd5561bf4f 15949286 update tcsh to 6.18.01
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents:
diff changeset
    34
 		if (ptr != bptr)
c2dd5561bf4f 15949286 update tcsh to 6.18.01
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents:
diff changeset
    35
 			buf = cat(buf, ptr, bptr - ptr);
c2dd5561bf4f 15949286 update tcsh to 6.18.01
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents:
diff changeset
    36
+		buf = cat(buf, "(", 0); /* ) */
c2dd5561bf4f 15949286 update tcsh to 6.18.01
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents:
diff changeset
    37
 		if ((eptr = strchr(ptr + sizeof(def) - 1, ')')) == NULL) {
c2dd5561bf4f 15949286 update tcsh to 6.18.01
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents:
diff changeset
    38
 			(void) fprintf(stderr, "%s: missing close paren `%s'\n",
c2dd5561bf4f 15949286 update tcsh to 6.18.01
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents:
diff changeset
    39
 			    pname, defs);
c2dd5561bf4f 15949286 update tcsh to 6.18.01
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents:
diff changeset
    40
+			free(buf);
c2dd5561bf4f 15949286 update tcsh to 6.18.01
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents:
diff changeset
    41
 			return defs;
c2dd5561bf4f 15949286 update tcsh to 6.18.01
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents:
diff changeset
    42
 		}
c2dd5561bf4f 15949286 update tcsh to 6.18.01
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents:
diff changeset
    43
 		buf = cat(buf, bptr, eptr - bptr + 1);
c2dd5561bf4f 15949286 update tcsh to 6.18.01
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents:
diff changeset
    44
@@ -186,26 +194,29 @@
c2dd5561bf4f 15949286 update tcsh to 6.18.01
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents:
diff changeset
    45
 		if (len < 1) {
c2dd5561bf4f 15949286 update tcsh to 6.18.01
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents:
diff changeset
    46
 			(void) fprintf(stderr, "%s: empty define `%s'\n",
c2dd5561bf4f 15949286 update tcsh to 6.18.01
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents:
diff changeset
    47
 			    pname, defs);
c2dd5561bf4f 15949286 update tcsh to 6.18.01
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents:
diff changeset
    48
+			free(buf);
c2dd5561bf4f 15949286 update tcsh to 6.18.01
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents:
diff changeset
    49
 			return defs;
c2dd5561bf4f 15949286 update tcsh to 6.18.01
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents:
diff changeset
    50
 		}
c2dd5561bf4f 15949286 update tcsh to 6.18.01
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents:
diff changeset
    51
 		if (*name != '_') {
c2dd5561bf4f 15949286 update tcsh to 6.18.01
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents:
diff changeset
    52
 			char *undername = malloc(len + 10);
c2dd5561bf4f 15949286 update tcsh to 6.18.01
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents:
diff changeset
    53
-			buf = cat(buf, " || defined(", 0);
c2dd5561bf4f 15949286 update tcsh to 6.18.01
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents:
diff changeset
    54
+			if (undername == NULL)
c2dd5561bf4f 15949286 update tcsh to 6.18.01
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents:
diff changeset
    55
+				abort();
c2dd5561bf4f 15949286 update tcsh to 6.18.01
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents:
diff changeset
    56
+			buf = cat(buf, ") || defined(", 0);
c2dd5561bf4f 15949286 update tcsh to 6.18.01
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents:
diff changeset
    57
 			snprintf(undername, len + 10, "__%.*s__)", (int)len,
c2dd5561bf4f 15949286 update tcsh to 6.18.01
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents:
diff changeset
    58
 			    name);
c2dd5561bf4f 15949286 update tcsh to 6.18.01
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents:
diff changeset
    59
 			buf = cat(buf, undername, len + 5);
c2dd5561bf4f 15949286 update tcsh to 6.18.01
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents:
diff changeset
    60
-			buf = cat(buf, " || defined(", 0);
c2dd5561bf4f 15949286 update tcsh to 6.18.01
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents:
diff changeset
    61
+			buf = cat(buf, ") || defined(", 0);
c2dd5561bf4f 15949286 update tcsh to 6.18.01
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents:
diff changeset
    62
 			snprintf(undername, len + 10, "__%.*s)", (int)len,
c2dd5561bf4f 15949286 update tcsh to 6.18.01
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents:
diff changeset
    63
 			    name);
c2dd5561bf4f 15949286 update tcsh to 6.18.01
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents:
diff changeset
    64
 			buf = cat(buf, undername, len + 3);
c2dd5561bf4f 15949286 update tcsh to 6.18.01
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents:
diff changeset
    65
 		}
c2dd5561bf4f 15949286 update tcsh to 6.18.01
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents:
diff changeset
    66
+		buf = cat(buf, "))", 0);
c2dd5561bf4f 15949286 update tcsh to 6.18.01
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents:
diff changeset
    67
 	}
c2dd5561bf4f 15949286 update tcsh to 6.18.01
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents:
diff changeset
    68
 	if (!eptr) {
c2dd5561bf4f 15949286 update tcsh to 6.18.01
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents:
diff changeset
    69
 	    (void) fprintf(stderr, "%s: invalid input `%s'\n", pname, defs);
c2dd5561bf4f 15949286 update tcsh to 6.18.01
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents:
diff changeset
    70
 	    return defs;
c2dd5561bf4f 15949286 update tcsh to 6.18.01
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents:
diff changeset
    71
         }
c2dd5561bf4f 15949286 update tcsh to 6.18.01
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents:
diff changeset
    72
 	buf = cat(buf, eptr + 1, 0);
c2dd5561bf4f 15949286 update tcsh to 6.18.01
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents:
diff changeset
    73
-	buf = cat(buf, ")", 0);
c2dd5561bf4f 15949286 update tcsh to 6.18.01
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents:
diff changeset
    74
 	return buf;
c2dd5561bf4f 15949286 update tcsh to 6.18.01
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents:
diff changeset
    75
 }
c2dd5561bf4f 15949286 update tcsh to 6.18.01
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents:
diff changeset
    76
 
c2dd5561bf4f 15949286 update tcsh to 6.18.01
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents:
diff changeset
    77
c2dd5561bf4f 15949286 update tcsh to 6.18.01
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents:
diff changeset
    78
RCS file: /p/tcsh/cvsroot/tcsh/gethost.c,v
c2dd5561bf4f 15949286 update tcsh to 6.18.01
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents:
diff changeset
    79
retrieving revision 1.16
c2dd5561bf4f 15949286 update tcsh to 6.18.01
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents:
diff changeset
    80
diff -u -r1.16 gethost.c
c2dd5561bf4f 15949286 update tcsh to 6.18.01
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents:
diff changeset
    81
--- tcsh-6.18.01/gethost.c.orig	4 Jan 2013 22:20:37 -0000	1.16
c2dd5561bf4f 15949286 update tcsh to 6.18.01
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents:
diff changeset
    82
+++ tcsh-6.18.01/gethost.c	5 Jan 2013 01:22:56 -0000
c2dd5561bf4f 15949286 update tcsh to 6.18.01
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents:
diff changeset
    83
@@ -180,7 +180,7 @@
c2dd5561bf4f 15949286 update tcsh to 6.18.01
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents:
diff changeset
    84
 	buf = NULL;
c2dd5561bf4f 15949286 update tcsh to 6.18.01
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents:
diff changeset
    85
 	for (ptr = defs; (bptr = strstr(ptr, def)) != NULL; ptr = eptr + 1) {
c2dd5561bf4f 15949286 update tcsh to 6.18.01
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents:
diff changeset
    86
 		if (ptr != bptr)
c2dd5561bf4f 15949286 update tcsh to 6.18.01
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents:
diff changeset
    87
-			buf = cat(buf, ptr, bptr - ptr);
c2dd5561bf4f 15949286 update tcsh to 6.18.01
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents:
diff changeset
    88
+			buf = cat(buf, ptr, bptr - ptr + 1);
c2dd5561bf4f 15949286 update tcsh to 6.18.01
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents:
diff changeset
    89
 		buf = cat(buf, "(", 0); /* ) */
c2dd5561bf4f 15949286 update tcsh to 6.18.01
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents:
diff changeset
    90
 		if ((eptr = strchr(ptr + sizeof(def) - 1, ')')) == NULL) {
c2dd5561bf4f 15949286 update tcsh to 6.18.01
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents:
diff changeset
    91
 			(void) fprintf(stderr, "%s: missing close paren `%s'\n",