Wed Jan 20 15:13:33 2016 UTC ()
sync with gcc.old (catch up with __RCSID removal and libc sync)


(christos)
diff -r1.3 -r1.4 src/external/gpl3/gcc/dist/gcc/final.c
diff -r1.2 -r1.3 src/external/gpl3/gcc/dist/gcc/regsub.c

cvs diff -r1.3 -r1.4 src/external/gpl3/gcc/dist/gcc/final.c (expand / switch to unified diff)

--- src/external/gpl3/gcc/dist/gcc/final.c 2016/01/09 02:05:00 1.3
+++ src/external/gpl3/gcc/dist/gcc/final.c 2016/01/20 15:13:33 1.4
@@ -1598,42 +1598,42 @@ add_debug_regex_map (const char *arg) @@ -1598,42 +1598,42 @@ add_debug_regex_map (const char *arg)
1598 free(old); 1598 free(old);
1599 return; 1599 return;
1600 } 1600 }
1601 free(old); 1601 free(old);
1602 1602
1603 map = XNEW (debug_regex_map); 1603 map = XNEW (debug_regex_map);
1604 map->re = re; 1604 map->re = re;
1605 p++; 1605 p++;
1606 map->sub = xstrdup (p); 1606 map->sub = xstrdup (p);
1607 map->next = debug_regex_maps; 1607 map->next = debug_regex_maps;
1608 debug_regex_maps = map; 1608 debug_regex_maps = map;
1609} 1609}
1610 1610
1611extern ssize_t aregsub(char **, const char *, 1611extern ssize_t regasub(char **, const char *,
1612 const regmatch_t *rm, const char *); 1612 const regmatch_t *rm, const char *);
1613 1613
1614/* Perform user-specified mapping of debug filename regular expressions. Return 1614/* Perform user-specified mapping of debug filename regular expressions. Return
1615 the new name corresponding to FILENAME. */ 1615 the new name corresponding to FILENAME. */
1616 1616
1617static const char * 1617static const char *
1618remap_debug_regex_filename (const char *filename) 1618remap_debug_regex_filename (const char *filename)
1619{ 1619{
1620 debug_regex_map *map; 1620 debug_regex_map *map;
1621 char *s; 1621 char *s;
1622 regmatch_t rm[10]; 1622 regmatch_t rm[10];
1623 1623
1624 for (map = debug_regex_maps; map; map = map->next) 1624 for (map = debug_regex_maps; map; map = map->next)
1625 if (regexec (&map->re, filename, 10, rm, 0) == 0 1625 if (regexec (&map->re, filename, 10, rm, 0) == 0
1626 && aregsub (&s, map->sub, rm, filename) >= 0) 1626 && regasub (&s, map->sub, rm, filename) >= 0)
1627 { 1627 {
1628 const char *name = ggc_strdup(s); 1628 const char *name = ggc_strdup(s);
1629 free(s); 1629 free(s);
1630 return name; 1630 return name;
1631 } 1631 }
1632 return filename; 1632 return filename;
1633} 1633}
1634 1634
1635const char * 1635const char *
1636remap_debug_filename (const char *filename) 1636remap_debug_filename (const char *filename)
1637{ 1637{
1638 return remap_debug_regex_filename (remap_debug_prefix_filename (filename)); 1638 return remap_debug_regex_filename (remap_debug_prefix_filename (filename));
1639} 1639}

cvs diff -r1.2 -r1.3 src/external/gpl3/gcc/dist/gcc/regsub.c (expand / switch to unified diff)

--- src/external/gpl3/gcc/dist/gcc/regsub.c 2016/01/16 19:28:36 1.2
+++ src/external/gpl3/gcc/dist/gcc/regsub.c 2016/01/20 15:13:33 1.3
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: regsub.c,v 1.2 2016/01/16 19:28:36 christos Exp $ */ 1/* $NetBSD: regsub.c,v 1.3 2016/01/20 15:13:33 christos Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 2015 The NetBSD Foundation, Inc. 4 * Copyright (c) 2015 The NetBSD Foundation, Inc.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * This code is derived from software contributed to The NetBSD Foundation 7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Christos Zoulas. 8 * by Christos Zoulas.
9 * 9 *
10 * Redistribution and use in source and binary forms, with or without 10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions 11 * modification, are permitted provided that the following conditions
12 * are met: 12 * are met:
13 * 1. Redistributions of source code must retain the above copyright 13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer. 14 * notice, this list of conditions and the following disclaimer.
@@ -18,57 +18,53 @@ @@ -18,57 +18,53 @@
18 * 18 *
19 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 19 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE. 29 * POSSIBILITY OF SUCH DAMAGE.
30 */ 30 */
31#include <sys/cdefs.h> 
32#ifdef __RCSID 
33__RCSID("$NetBSD: regsub.c,v 1.2 2016/01/16 19:28:36 christos Exp $"); 
34#endif 
35 
36#include <sys/param.h> 31#include <sys/param.h>
37 
38#include <ctype.h> 32#include <ctype.h>
39#include <stdlib.h> 33#include <stdlib.h>
40#include <string.h> 34#include <string.h>
41#include <regex.h> 35#include <regex.h>
42 36
43struct str { 37struct str {
44 char *s_ptr; 38 char *s_ptr;
45 size_t s_max; 39 size_t s_max;
46 size_t s_len; 40 size_t s_len;
47 int s_fixed; 41 int s_fixed;
48}; 42};
49 43
 44#define REINCR 64
 45
50static int 46static int
51addspace(struct str *s, size_t len) 47addspace(struct str *s, size_t len)
52{ 48{
53 void *v; 49 void *v;
54 50
55 if (s->s_max - s->s_len > len) 51 if (s->s_max - s->s_len > len)
56 return 0; 52 return 0;
57 53
58 if (s->s_fixed) 54 if (s->s_fixed)
59 return -1; 55 return -1;
60 56
61 s->s_max += MAX(len, 64); 57 s->s_max += len + REINCR;
62 58
63 v = realloc(s->s_ptr, s->s_max); 59 v = realloc(s->s_ptr, s->s_max);
64 if (v == NULL) 60 if (v == NULL)
65 return -1; 61 return -1;
66 s->s_ptr = (char *)v; 62 s->s_ptr = (char *)v;
67 63
68 return 0; 64 return 0;
69} 65}
70 66
71static void 67static void
72addchar(struct str *s, int c) 68addchar(struct str *s, int c)
73{ 69{
74 if (addspace(s, 1) == -1) 70 if (addspace(s, 1) == -1)
@@ -83,37 +79,37 @@ addchar(struct str *s, int c) @@ -83,37 +79,37 @@ addchar(struct str *s, int c)
83 79
84static void 80static void
85addnstr(struct str *s, const char *buf, size_t len) 81addnstr(struct str *s, const char *buf, size_t len)
86{ 82{
87 if (addspace(s, len) != -1) 83 if (addspace(s, len) != -1)
88 memcpy(s->s_ptr + s->s_len, buf, len); 84 memcpy(s->s_ptr + s->s_len, buf, len);
89 s->s_len += len; 85 s->s_len += len;
90} 86}
91 87
92static int 88static int
93initstr(struct str *s, char *buf, size_t len) 89initstr(struct str *s, char *buf, size_t len)
94{ 90{
95 s->s_max = len; 91 s->s_max = len;
96 s->s_ptr = buf == NULL ? (char *)malloc(len) : buf; 92 s->s_ptr = (char *)(buf == NULL ? malloc(len) : buf);
97 s->s_fixed = buf != NULL; 93 s->s_fixed = buf != NULL;
98 s->s_len = 0; 94 s->s_len = 0;
99 return s->s_ptr == NULL ? -1 : 0; 95 return s->s_ptr == NULL ? -1 : 0;
100} 96}
101 97
102static ssize_t 98static ssize_t
103regsub1(char **buf, size_t len, const char *sub, 99regsub1(char **buf, size_t len, const char *sub,
104 const regmatch_t *rm, const char *str) 100 const regmatch_t *rm, const char *str)
105{ 101{
106 ssize_t i;  102 ssize_t i;
107 char c;  103 char c;
108 struct str s; 104 struct str s;
109 105
110 if (initstr(&s, *buf, len) == -1) 106 if (initstr(&s, *buf, len) == -1)
111 return -1; 107 return -1;
112 108
113 while ((c = *sub++) != '\0') { 109 while ((c = *sub++) != '\0') {
114 110
115 switch (c) { 111 switch (c) {
116 case '&': 112 case '&':
117 i = 0; 113 i = 0;
118 break; 114 break;
119 case '\\': 115 case '\\':
@@ -139,25 +135,25 @@ regsub1(char **buf, size_t len, const ch @@ -139,25 +135,25 @@ regsub1(char **buf, size_t len, const ch
139 135
140 addchar(&s, '\0'); 136 addchar(&s, '\0');
141 if (!s.s_fixed) { 137 if (!s.s_fixed) {
142 if (s.s_len >= s.s_max) { 138 if (s.s_len >= s.s_max) {
143 free(s.s_ptr); 139 free(s.s_ptr);
144 return -1; 140 return -1;
145 } 141 }
146 *buf = s.s_ptr; 142 *buf = s.s_ptr;
147 } 143 }
148 return s.s_len; 144 return s.s_len;
149} 145}
150 146
151ssize_t 147ssize_t
152regsub(char *buf, size_t len, const char *sub, const regmatch_t *rm, 148regnsub(char *buf, size_t len, const char *sub, const regmatch_t *rm,
153 const char *str) 149 const char *str)
154{ 150{
155 return regsub1(&buf, len, sub, rm, str); 151 return regsub1(&buf, len, sub, rm, str);
156} 152}
157 153
158ssize_t 154ssize_t
159aregsub(char **buf, const char *sub, const regmatch_t *rm, const char *str) 155regasub(char **buf, const char *sub, const regmatch_t *rm, const char *str)
160{ 156{
161 *buf = NULL; 157 *buf = NULL;
162 return regsub1(buf, 64, sub, rm, str); 158 return regsub1(buf, REINCR, sub, rm, str);
163} 159}