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