comparison libiberty/d-demangle.c @ 145:1830386684a0

gcc-9.2.0
author anatofuz
date Thu, 13 Feb 2020 11:34:05 +0900
parents 84e7813d76e9
children
comparison
equal deleted inserted replaced
131:84e7813d76e9 145:1830386684a0
1 /* Demangler for the D programming language 1 /* Demangler for the D programming language
2 Copyright (C) 2014-2018 Free Software Foundation, Inc. 2 Copyright (C) 2014-2020 Free Software Foundation, Inc.
3 Written by Iain Buclaw (ibuclaw@gdcproject.org) 3 Written by Iain Buclaw (ibuclaw@gdcproject.org)
4 4
5 This file is part of the libiberty library. 5 This file is part of the libiberty library.
6 Libiberty is free software; you can redistribute it and/or 6 Libiberty is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Library General Public 7 modify it under the terms of the GNU Library General Public
937 dlang_parse_integer (string *decl, const char *mangled, char type) 937 dlang_parse_integer (string *decl, const char *mangled, char type)
938 { 938 {
939 if (type == 'a' || type == 'u' || type == 'w') 939 if (type == 'a' || type == 'u' || type == 'w')
940 { 940 {
941 /* Parse character value. */ 941 /* Parse character value. */
942 char value[10]; 942 char value[20];
943 int pos = 10; 943 int pos = sizeof(value);
944 int width = 0; 944 int width = 0;
945 long val; 945 long val;
946 946
947 mangled = dlang_number (mangled, &val); 947 mangled = dlang_number (mangled, &val);
948 if (mangled == NULL) 948 if (mangled == NULL)
989 } 989 }
990 990
991 for (; width > 0; width--) 991 for (; width > 0; width--)
992 value[--pos] = '0'; 992 value[--pos] = '0';
993 993
994 string_appendn (decl, &(value[pos]), 10 - pos); 994 string_appendn (decl, &(value[pos]), sizeof(value) - pos);
995 } 995 }
996 string_append (decl, "'"); 996 string_append (decl, "'");
997 } 997 }
998 else if (type == 'b') 998 else if (type == 'b')
999 { 999 {
1189 1189
1190 string_append (decl, "["); 1190 string_append (decl, "[");
1191 while (elements--) 1191 while (elements--)
1192 { 1192 {
1193 mangled = dlang_value (decl, mangled, NULL, '\0'); 1193 mangled = dlang_value (decl, mangled, NULL, '\0');
1194 if (mangled == NULL)
1195 return NULL;
1196
1194 if (elements != 0) 1197 if (elements != 0)
1195 string_append (decl, ", "); 1198 string_append (decl, ", ");
1196 } 1199 }
1197 1200
1198 string_append (decl, "]"); 1201 string_append (decl, "]");
1212 1215
1213 string_append (decl, "["); 1216 string_append (decl, "[");
1214 while (elements--) 1217 while (elements--)
1215 { 1218 {
1216 mangled = dlang_value (decl, mangled, NULL, '\0'); 1219 mangled = dlang_value (decl, mangled, NULL, '\0');
1220 if (mangled == NULL)
1221 return NULL;
1222
1217 string_append (decl, ":"); 1223 string_append (decl, ":");
1218 mangled = dlang_value (decl, mangled, NULL, '\0'); 1224 mangled = dlang_value (decl, mangled, NULL, '\0');
1225 if (mangled == NULL)
1226 return NULL;
1219 1227
1220 if (elements != 0) 1228 if (elements != 0)
1221 string_append (decl, ", "); 1229 string_append (decl, ", ");
1222 } 1230 }
1223 1231
1241 1249
1242 string_append (decl, "("); 1250 string_append (decl, "(");
1243 while (args--) 1251 while (args--)
1244 { 1252 {
1245 mangled = dlang_value (decl, mangled, NULL, '\0'); 1253 mangled = dlang_value (decl, mangled, NULL, '\0');
1254 if (mangled == NULL)
1255 return NULL;
1256
1246 if (args != 0) 1257 if (args != 0)
1247 string_append (decl, ", "); 1258 string_append (decl, ", ");
1248 } 1259 }
1249 1260
1250 string_append (decl, ")"); 1261 string_append (decl, ")");
1495 string_append (decl, "Tuple!("); 1506 string_append (decl, "Tuple!(");
1496 1507
1497 while (elements--) 1508 while (elements--)
1498 { 1509 {
1499 mangled = dlang_type (decl, mangled); 1510 mangled = dlang_type (decl, mangled);
1511 if (mangled == NULL)
1512 return NULL;
1513
1500 if (elements != 0) 1514 if (elements != 0)
1501 string_append (decl, ", "); 1515 string_append (decl, ", ");
1502 } 1516 }
1503 1517
1504 string_append (decl, ")"); 1518 string_append (decl, ")");