xref: /illumos-gate/usr/src/cmd/sgs/libelf/misc/nplist.c (revision 2a8bcb4e)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  *	Copyright (c) 1988 AT&T
24  *	  All Rights Reserved
25  *
26  *
27  *	Copyright (c) 1999 by Sun Microsystems, Inc.
28  *	All rights reserved.
29  */
30 
31 #include	"elf_dem.h"
32 #include	<string.h>
33 #include	"msg.h"
34 
35 struct name_pair {
36 #ifdef __lint
37 	char	* s1, * s2;
38 #else
39 	int	s1, s2;
40 #endif
41 };
42 
43 struct name_pair nplist[100] = {
44 	/* MSG_ORIG(MSG_STR_LT)		MSG_ORIG(MSG_STR_OPNANGBRAK) */
45 	{ MSG_STR_LT,	MSG_STR_OPNANGBRAK },
46 	/* MSG_ORIG(MSG_STR_LS)		MSG_ORIG(MSG_STR_DBLOPNANGBRAK) */
47 	{ MSG_STR_LS,	MSG_STR_DBLOPNANGBRAK },
48 	/* MSG_ORIG(MSG_STR_DV)		MSG_ORIG(MSG_STR_SLASH) */
49 	{ MSG_STR_DV,	MSG_STR_SLASH },
50 	/* MSG_ORIG(MSG_STR_GT)		MSG_ORIG(MSG_STR_CLOANGBRAK) */
51 	{ MSG_STR_GT,	MSG_STR_CLOANGBRAK },
52 	/* MSG_ORIG(MSG_STR_RS)		MSG_ORIG(MSG_STR_DBLCLOANGBRAK) */
53 	{ MSG_STR_RS,	MSG_STR_DBLCLOANGBRAK },
54 	/* MSG_ORIG(MSG_STR_MD)		MSG_ORIG(MSG_STR_PERCENT) */
55 	{ MSG_STR_MD,	MSG_STR_PERCENT },
56 	/* MSG_ORIG(MSG_STR_LE)		MSG_ORIG(MSG_STR_OPNANGBRAKEQU) */
57 	{ MSG_STR_LE,	MSG_STR_OPNANGBRAKEQU },
58 	/* MSG_ORIG(MSG_STR_ML)		MSG_ORIG(MSG_STR_STAR) */
59 	{ MSG_STR_ML,	MSG_STR_STAR },
60 	/* MSG_ORIG(MSG_STR_PL)		MSG_ORIG(MSG_STR_PLUS) */
61 	{ MSG_STR_PL,	MSG_STR_PLUS },
62 	/* MSG_ORIG(MSG_STR_GE)		MSG_ORIG(MSG_STR_CLOANGBRAKEQU) */
63 	{ MSG_STR_GE,	MSG_STR_CLOANGBRAKEQU },
64 	/* MSG_ORIG(MSG_STR_AD)		MSG_ORIG(MSG_STR_AMP) */
65 	{ MSG_STR_AD,	MSG_STR_AMP },
66 	/* MSG_ORIG(MSG_STR_MI)		MSG_ORIG(MSG_STR_MINUS) */
67 	{ MSG_STR_MI,	MSG_STR_MINUS },
68 	/* MSG_ORIG(MSG_STR_NE)		MSG_ORIG(MSG_STR_BANGEQU) */
69 	{ MSG_STR_NE,	MSG_STR_BANGEQU },
70 	/* MSG_ORIG(MSG_STR_OR)		MSG_ORIG(MSG_STR_PIPE) */
71 	{ MSG_STR_OR,	MSG_STR_PIPE },
72 	/* MSG_ORIG(MSG_STR_ER)		MSG_ORIG(MSG_STR_CARAT) */
73 	{ MSG_STR_ER,	MSG_STR_CARAT },
74 	/* MSG_ORIG(MSG_STR_AA)		MSG_ORIG(MSG_STR_DBLAMP) */
75 	{ MSG_STR_AA,	MSG_STR_DBLAMP },
76 	/* MSG_ORIG(MSG_STR_OO)		MSG_ORIG(MSG_STR_DBLPIPE) */
77 	{ MSG_STR_OO,	MSG_STR_DBLPIPE },
78 	/* MSG_ORIG(MSG_STR_AS)		MSG_ORIG(MSG_STR_EQU) */
79 	{ MSG_STR_AS,	MSG_STR_EQU },
80 	/* MSG_ORIG(MSG_STR_APL)	MSG_ORIG(MSG_STR_PLUSEQU) */
81 	{ MSG_STR_APL,	MSG_STR_PLUSEQU },
82 	/* MSG_ORIG(MSG_STR_AMI)	MSG_ORIG(MSG_STR_MINUSEQU) */
83 	{ MSG_STR_AMI,	MSG_STR_MINUSEQU },
84 	/* MSG_ORIG(MSG_STR_AMU)	MSG_ORIG(MSG_STR_STARTEQU) */
85 	{ MSG_STR_AMU,	MSG_STR_STARTEQU },
86 	/* MSG_ORIG(MSG_STR_ADV)	MSG_ORIG(MSG_STR_SLASHEQU) */
87 	{ MSG_STR_ADV,	MSG_STR_SLASHEQU },
88 	/* MSG_ORIG(MSG_STR_AMD)	MSG_ORIG(MSG_STR_PERCENTEQU) */
89 	{ MSG_STR_AMD,	MSG_STR_PERCENTEQU },
90 	/* MSG_ORIG(MSG_STR_AAD)	MSG_ORIG(MSG_STR_AMPEQU) */
91 	{ MSG_STR_AAD,	MSG_STR_AMPEQU },
92 	/* MSG_ORIG(MSG_STR_AOR)	MSG_ORIG(MSG_STR_PIPEEQU) */
93 	{ MSG_STR_AOR,	MSG_STR_PIPEEQU },
94 	/* MSG_ORIG(MSG_STR_AER)	MSG_ORIG(MSG_STR_CARATEQU) */
95 	{ MSG_STR_AER,	MSG_STR_CARATEQU },
96 	/* MSG_ORIG(MSG_STR_ALS)	MSG_ORIG(MSG_STR_DBLOPENABKEQU) */
97 	{ MSG_STR_ALS,	MSG_STR_DBLOPENABKEQU },
98 	/* MSG_ORIG(MSG_STR_ARS)	MSG_ORIG(MSG_STR_DBLCLOSABKEQU) */
99 	{ MSG_STR_ARS,	MSG_STR_DBLCLOSABKEQU },
100 	/* MSG_ORIG(MSG_STR_PP)		MSG_ORIG(MSG_STR_DBLPLUS) */
101 	{ MSG_STR_PP,	MSG_STR_DBLPLUS },
102 	/* MSG_ORIG(MSG_STR_MM)		MSG_ORIG(MSG_STR_DBLMINUS) */
103 	{ MSG_STR_MM,	MSG_STR_DBLMINUS },
104 	/* MSG_ORIG(MSG_STR_VC)		MSG_ORIG(MSG_STR_OPENCLOBRAK) */
105 	{ MSG_STR_VC,	MSG_STR_OPENCLOBRAK },
106 	/* MSG_ORIG(MSG_STR_CL)		MSG_ORIG(MSG_STR_OPENCLOSEPAR) */
107 	{ MSG_STR_CL,	MSG_STR_OPENCLOSEPAR },
108 	/* MSG_ORIG(MSG_STR_RF)		MSG_ORIG(MSG_STR_MINUSCLOANGBK) */
109 	{ MSG_STR_RF,	MSG_STR_MINUSCLOANGBK },
110 	/* MSG_ORIG(MSG_STR_EQ)		MSG_ORIG(MSG_STR_DBLEQU) */
111 	{ MSG_STR_EQ,	MSG_STR_DBLEQU },
112 	/* MSG_ORIG(MSG_STR_CO)		MSG_ORIG(MSG_STR_TILDE) */
113 	{ MSG_STR_CO,	MSG_STR_TILDE },
114 	/* MSG_ORIG(MSG_STR_NT)		MSG_ORIG(MSG_STR_BANG) */
115 	{ MSG_STR_NT,	MSG_STR_BANG },
116 	/* MSG_ORIG(MSG_STR_NW)		MSG_ORIG(MSG_STR_NEW) */
117 	{ MSG_STR_NW,	MSG_STR_NEW },
118 	/* MSG_ORIG(MSG_STR_DL)		MSG_ORIG(MSG_STR_DELETE) */
119 	{ MSG_STR_DL,	MSG_STR_DELETE },
120 	{ 0,		0 }
121 };
122 
123 /* This routine demangles an overloaded operator function */
124 const char *
findop(char * c,int * oplen)125 findop(char * c, int * oplen)
126 {
127 	register int i, opl;
128 
129 	for (opl = 0; c[opl] && c[opl] != '_'; opl++)
130 		;
131 	*oplen = opl;
132 
133 	for (i = 0; nplist[i].s1; i++) {
134 		if (strncmp(MSG_ORIG(nplist[i].s1), c, opl) == 0)
135 			return (MSG_ORIG(nplist[i].s2));
136 	}
137 	return (0);
138 }
139