@@ -40,23 +40,19 @@ EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
4040#include <stdlib.h> /* atol() exit() getenv() */
4141#include <string.h> /* strcmp() strlen() strncmp() */
4242
43- #include "libdwarf.h"
44- #include "libdwarf_private.h"
45-
4643#define TRUE 1
4744#define FALSE 0
4845
4946/* We don't allow arbitrary DW_DLE line length. */
5047#define MAXDEFINELINE 1000
5148static char buffer [MAXDEFINELINE ];
52- static char buffer2 [MAXDEFINELINE ];
5349
5450/* Arbitrary. A much smaller max length value would work. */
5551#define MAX_NUM_LENGTH 12
5652
5753/* Increase this when the actual number of DW_LNAME_name
5854 instances approaches this number. */
59- #define MAX_LNAME_LEN 20
55+ #define MAX_LNAME_LEN 30
6056#define LNAME_INSTANCE_MAX 100
6157struct instance_s {
6258 char name [MAX_LNAME_LEN ];
@@ -69,7 +65,7 @@ int header_count;
6965struct instance_s csource [LNAME_INSTANCE_MAX ];
7066int csource_count ;
7167
72- void
68+ static void
7369_dwarf_safe_strcpy (char * out ,
7470 size_t outlen ,
7571 const char * in_s ,
@@ -100,7 +96,7 @@ _dwarf_safe_strcpy(char *out,
10096 * cpo = 0 ;
10197}
10298
103- void
99+ static void
104100check_for_dup (struct instance_s * ary ,int count ,
105101 char * name , const char * msg )
106102{
@@ -117,7 +113,7 @@ check_for_dup(struct instance_s *ary,int count,
117113}
118114
119115/* return TRUE on error */
120- static int
116+ static void
121117check_hdr_match (void )
122118{
123119 int k = 0 ;
@@ -135,8 +131,8 @@ check_hdr_match(void)
135131 foundh = FALSE;
136132 foundc = FALSE;
137133
138- for ( ; l < csource_count ; ++ l ) {
139- struct instance_s * curc = & csource [k ];
134+ for (l = 0 ; l < csource_count ; ++ l ) {
135+ struct instance_s * curc = & csource [l ];
140136
141137 if (strcmp (curh -> name ,curc -> name )) {
142138 continue ;
@@ -145,18 +141,19 @@ check_hdr_match(void)
145141 foundh = TRUE;
146142 curc -> count ++ ;
147143 if (curc -> count > 1 ) {
148- printf ("FAIL DUP %s in csource\n" ,
149- curc -> name );
144+ printf ("FAIL DUP %s in csource count %d \n" ,
145+ curc -> name , curc -> count );
150146 exit (EXIT_FAILURE );
151147 }
148+ break ;
152149 }
153150 if (!foundc ) {
154- printf ("FAIL to find %s in csource\n" ,
151+ printf ("FAIL to find curc %s in csource\n" ,
155152 curh -> name );
156153 exit (EXIT_FAILURE );
157154 }
158155 if (!foundh ) {
159- printf ("FAIL to find %s in csource\n" ,
156+ printf ("FAIL to find curh %s in csource\n" ,
160157 curh -> name );
161158 exit (EXIT_FAILURE );
162159 }
@@ -172,15 +169,11 @@ read_lname_csrc(char *path)
172169 /* The format should be
173170 case<space>name<colon> */
174171 unsigned linenum = 0 ;
175- unsigned long prevdefval = 0 ;
176- unsigned cur_dle_line = 0 ;
177- unsigned foundlast = 0 ;
178- unsigned foundlouser = 0 ;
179172 FILE * fin = 0 ;
180173
181174 fin = fopen (path , "r" );
182175 if (!fin ) {
183- printf ("Unable to open define list to read %s\n" ,path );
176+ printf ("Unable to open define csource to read %s\n" ,path );
184177 exit (EXIT_FAILURE );
185178 }
186179 for ( ;;++ linenum ) {
@@ -189,9 +182,6 @@ read_lname_csrc(char *path)
189182 char * curdefname = 0 ;
190183 char * pastname = 0 ;
191184 unsigned curdefname_len = 0 ;
192- char * numstart = 0 ;
193- char * endptr = 0 ;
194- unsigned long v = 0 ;
195185 int name_ok = FALSE;
196186
197187 line = fgets (buffer ,MAXDEFINELINE ,fin );
@@ -203,26 +193,27 @@ read_lname_csrc(char *path)
203193 line [linelen - 1 ] = 0 ;
204194 -- linelen ;
205195 if (linelen >= (unsigned )(MAXDEFINELINE - 1 )) {
206- printf ("define line %u is too long!\n" ,linenum );
196+ printf ("case line %u is too long!\n" ,linenum );
207197 exit (EXIT_FAILURE );
208198 }
209199 if (strncmp (line ," case DW_LNAME_" ,18 )) {
210200 /* Skip the non- case DW_LNAME lines */
211201 continue ;
212202 }
213- curdefname = line + 10 ;
203+ curdefname = line + 9 ;
214204 /* ASSERT: line ends with NUL byte. */
215205 for ( ; ; curdefname_len ++ ) {
216206 pastname = curdefname + curdefname_len ;
217207 if (!* pastname ) {
218208 /* At end of line. Missing value. */
219- printf ("define line %u of %s: has no number value! \n" ,
209+ printf ("WARNING: csrc case name has no comment %d %s \n" ,
220210 linenum ,path );
221- exit ( EXIT_FAILURE ) ;
211+ continue ;
222212 }
223213 if (* pastname == ' ' || * pastname == ':' ) {
224214 /* Ok. Now insert into table. */
225215 name_ok = TRUE;
216+ -- curdefname_len ;
226217 * pastname = 0 ;
227218 break ;
228219 }
@@ -232,12 +223,7 @@ read_lname_csrc(char *path)
232223 csource_count ,__LINE__ );
233224 exit (EXIT_FAILURE );
234225 }
235- if (header_count + 1 != v ) {
236- printf (" Fail checking defines: count %d v %d\n" ,
237- header_count ,(int )v );
238- exit (EXIT_FAILURE );
239- }
240- if (strlen (curdefname )+ 1 <= MAX_LNAME_LEN ) {
226+ if (strlen (curdefname )+ 1 >= MAX_LNAME_LEN ) {
241227 printf ("Name %s is too long for table at %u\n" ,
242228 curdefname ,
243229 (unsigned )strlen (curdefname ));
@@ -264,15 +250,11 @@ read_lname_hdr(char *path)
264250 and we are intentionally quite rigid about it all except
265251 that the number of spaces before any comment is allowed. */
266252 unsigned linenum = 0 ;
267- unsigned long prevdefval = 0 ;
268- unsigned cur_dle_line = 0 ;
269- unsigned foundlast = 0 ;
270- unsigned foundlouser = 0 ;
271253 FILE * fin = 0 ;
272254
273255 fin = fopen (path , "r" );
274256 if (!fin ) {
275- printf ("Unable to open define list to read %s\n" ,path );
257+ printf ("Unable to open define dwarf.h to read %s\n" ,path );
276258 exit (EXIT_FAILURE );
277259 }
278260 for ( ;;++ linenum ) {
@@ -298,19 +280,13 @@ read_lname_hdr(char *path)
298280 printf ("define line %u is too long!\n" ,linenum );
299281 exit (EXIT_FAILURE );
300282 }
301- if (strncmp (line ,"#define DW_LNAME__" , 21 )) {
283+ if (strncmp (line ,"#define DW_LNAME_" , 17 )) {
302284 /* Skip the non- DW_DLE_ lines */
303285 continue ;
304286 }
305287 curdefname = line + 8 ;
306288 /* ASSERT: line ends with NUL byte. */
307289 for ( ; ; curdefname_len ++ ) {
308- if (foundlouser ) {
309- printf ("define line %u has stuff after "
310- "DW_DLE_LO_USER!\n" ,
311- linenum );
312- exit (EXIT_FAILURE );
313- }
314290 pastname = curdefname + curdefname_len ;
315291 if (!* pastname ) {
316292 /* At end of line. Missing value. */
@@ -353,12 +329,12 @@ read_lname_hdr(char *path)
353329 linenum ,e ,e ,line );
354330 exit (EXIT_FAILURE );
355331 }
356- if (header_count + 1 != v ) {
332+ if (( header_count + 1 ) != ( int ) v ) {
357333 printf (" Fail checking defines: count %d v %d line %d\n" ,
358334 header_count ,(int )v , __LINE__ );
359335 exit (EXIT_FAILURE );
360336 }
361- if (strlen (curdefname )+ 1 < = MAX_LNAME_LEN ) {
337+ if (strlen (curdefname )+ 1 > = MAX_LNAME_LEN ) {
362338 printf ("Name %s is too long for table at %d\n" ,
363339 curdefname ,
364340 (int )strlen (curdefname ));
@@ -377,31 +353,6 @@ read_lname_hdr(char *path)
377353 fclose (fin );
378354}
379355
380- #if 0
381- static void
382- read_next_line (FILE * fin ,unsigned linenum ,unsigned int * quotedlen )
383- {
384- char * line = 0 ;
385- size_t linelen = 0 ;
386- unsigned int qlen2 = 0 ;
387-
388- line = fgets (buffer2 ,MAXDEFINELINE ,fin );
389- if (!line ) {
390- printf ("inner end file line %u is too long!\n" ,linenum );
391- exit (EXIT_FAILURE );
392- }
393- linelen = strlen (line );
394- line [linelen - 1 ] = 0 ;
395- -- linelen ;
396- if (linelen >= (unsigned long )(MAXDEFINELINE - 1 )) {
397- printf ("inner line %u is too long!\n" ,linenum );
398- exit (EXIT_FAILURE );
399- }
400- quoted_length (line ,& qlen2 );
401- * quotedlen = qlen2 ;
402- }
403-
404- #endif
405356static char pathbufhdr [2000 ];
406357static char pathbufc [2000 ];
407358static void
@@ -423,7 +374,6 @@ local_safe_strcpy(char *targ,char *src,
423374int
424375main (int argc , char * * argv )
425376{
426- unsigned i = 0 ;
427377 char * path = 0 ;
428378 size_t len = 0 ;
429379 const char * libpath = "/src/lib/libdwarf/dwarf.h" ;
0 commit comments