1 /* symbols.c -symbol table-
3 Copyright (C) 1987, 1990, 1991, 1992 Free Software Foundation, Inc.
5 This file is part of GAS, the GNU Assembler.
7 GAS is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2, or (at your option)
12 GAS is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with GAS; see the file COPYING. If not, write to
19 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
25 #include "obstack.h" /* For "symbols.h" */
28 #ifndef WORKING_DOT_WORD
29 extern int new_broken_words
;
32 extern char const_flag
;
37 sy_hash
; /* symbol-name => struct symbol pointer */
39 /* Below are commented in "symbols.h". */
40 symbolS
*symbol_rootP
;
41 symbolS
*symbol_lastP
;
44 symbolS
*dot_text_symbol
;
45 symbolS
*dot_data_symbol
;
46 symbolS
*dot_bss_symbol
;
50 static void fb_label_init
PARAMS ((void));
56 symbol_rootP
= NULL
; /* In case we have 0 symbols (!!) */
57 sy_hash
= hash_new ();
58 memset ((char *) (&abs_symbol
), '\0', sizeof (abs_symbol
));
59 S_SET_SEGMENT (&abs_symbol
, SEG_ABSOLUTE
); /* Can't initialise a union. Sigh. */
60 #ifdef LOCAL_LABELS_FB
62 #endif /* LOCAL_LABELS_FB */
68 * Return a pointer to a new symbol.
69 * Die if we can't make a new symbol.
70 * Fill in the symbol's values.
71 * Add symbol to end of symbol chain.
74 * Please always call this to create a new symbol.
76 * Changes since 1985: Symbol names may not contain '\0'. Sigh.
77 * 2nd argument is now a SEG rather than a TYPE. The mapping between
78 * segments and types is mostly encapsulated herein (actually, we inherit it
79 * from macros in struc-symbol.h).
83 symbol_new (name
, segment
, value
, frag
)
84 char *name
; /* It is copied, the caller can destroy/modify */
85 segT segment
; /* Segment identifier (SEG_<something>) */
86 long value
; /* Symbol value */
87 fragS
*frag
; /* Associated fragment */
89 unsigned int name_length
;
90 char *preserved_copy_of_name
;
93 name_length
= strlen (name
) + 1; /* +1 for \0 */
94 obstack_grow (¬es
, name
, name_length
);
95 preserved_copy_of_name
= obstack_finish (¬es
);
96 symbolP
= (symbolS
*) obstack_alloc (¬es
, sizeof (symbolS
));
98 /* symbol must be born in some fixed state. This seems as good as any. */
99 memset (symbolP
, 0, sizeof (symbolS
));
101 #ifdef STRIP_UNDERSCORE
102 S_SET_NAME (symbolP
, (*preserved_copy_of_name
== '_'
103 ? preserved_copy_of_name
+ 1
104 : preserved_copy_of_name
));
105 #else /* STRIP_UNDERSCORE */
106 S_SET_NAME (symbolP
, preserved_copy_of_name
);
107 #endif /* STRIP_UNDERSCORE */
109 S_SET_SEGMENT (symbolP
, segment
);
110 S_SET_VALUE (symbolP
, value
);
111 /* symbol_clear_list_pointers(symbolP); uneeded if symbol is born zeroed. */
113 symbolP
->sy_frag
= frag
;
114 /* krm: uneeded if symbol is born zeroed.
115 symbolP->sy_forward = NULL; *//* JF */
116 symbolP
->sy_number
= ~0;
117 symbolP
->sy_name_offset
= ~0;
120 * Link to end of symbol chain.
122 symbol_append (symbolP
, symbol_lastP
, &symbol_rootP
, &symbol_lastP
);
124 obj_symbol_new_hook (symbolP
);
127 /* verify_symbol_chain(symbol_rootP, symbol_lastP); */
137 * We have just seen "<name>:".
138 * Creates a struct symbol unless it already exists.
140 * Gripes if we are redefining a symbol incompatibly (and ignores it).
144 colon (sym_name
) /* just seen "x:" - rattle symbols & frags */
145 register char *sym_name
; /* symbol name, as a cannonical string */
146 /* We copy this string: OK to alter later. */
148 register symbolS
*symbolP
; /* symbol we are working with */
150 #ifdef LOCAL_LABELS_DOLLAR
151 /* Sun local labels go out of scope whenever a non-local symbol is defined. */
153 if (*sym_name
!= 'L')
154 dollar_label_clear ();
155 #endif /* LOCAL_LABELS_DOLLAR */
157 #ifndef WORKING_DOT_WORD
158 if (new_broken_words
)
160 struct broken_word
*a
;
165 extern md_short_jump_size
;
166 extern md_long_jump_size
;
167 possible_bytes
= md_short_jump_size
+ new_broken_words
* md_long_jump_size
;
170 frag_opcode
= frag_var (rs_broken_word
,
174 (symbolS
*) broken_words
,
178 /* We want to store the pointer to where to insert the jump table in the
179 fr_opcode of the rs_broken_word frag. This requires a little hackery */
180 while (frag_tmp
&& (frag_tmp
->fr_type
!= rs_broken_word
|| frag_tmp
->fr_opcode
))
181 frag_tmp
= frag_tmp
->fr_next
;
183 frag_tmp
->fr_opcode
= frag_opcode
;
184 new_broken_words
= 0;
186 for (a
= broken_words
; a
&& a
->dispfrag
== 0; a
= a
->next_broken_word
)
187 a
->dispfrag
= frag_tmp
;
189 #endif /* WORKING_DOT_WORD */
191 if ((symbolP
= symbol_find (sym_name
)) != 0)
195 * If the new symbol is .comm AND it has a size of zero,
196 * we ignore it (i.e. the old symbol overrides it)
198 if ((SEGMENT_TO_SYMBOL_TYPE ((int) now_seg
) == (N_UNDF
| N_EXT
)) &&
199 ((obstack_next_free (&frags
) - frag_now
->fr_literal
) == 0))
202 * If the old symbol is .comm and it has a size of zero,
203 * we override it with the new symbol value.
205 if ((symbolP
->sy_type
== (N_UNDF
| N_EXT
))
206 && (S_GET_VALUE (symbolP
) == 0))
208 symbolP
->sy_frag
= frag_now
;
209 symbolP
->sy_other
= const_flag
;
210 S_SET_VALUE (symbolP
, obstack_next_free (&frags
) - frag_now
->fr_literal
);
211 symbolP
->sy_type
|= SEGMENT_TO_SYMBOL_TYPE ((int) now_seg
); /* keep N_EXT bit */
216 * Now check for undefined symbols
218 if (!S_IS_DEFINED (symbolP
))
220 if (S_GET_VALUE (symbolP
) == 0)
222 symbolP
->sy_frag
= frag_now
;
224 symbolP
->sy_other
= const_flag
;
226 S_SET_VALUE (symbolP
, obstack_next_free (&frags
) - frag_now
->fr_literal
);
227 S_SET_SEGMENT (symbolP
, now_seg
);
230 #endif /* if we have one, it better be zero. */
236 * There are still several cases to check:
237 * A .comm/.lcomm symbol being redefined as
238 * initialized data is OK
239 * A .comm/.lcomm symbol being redefined with
240 * a larger size is also OK
242 * This only used to be allowed on VMS gas, but Sun cc
243 * on the sparc also depends on it.
245 /* char New_Type = SEGMENT_TO_SYMBOL_TYPE((int) now_seg); */
247 #define SEG_BSS SEG_E2
248 #define SEG_DATA SEG_E1
251 if (((!S_IS_DEBUG (symbolP
) && !S_IS_DEFINED (symbolP
) && S_IS_EXTERNAL (symbolP
))
252 || (S_GET_SEGMENT (symbolP
) == SEG_BSS
))
253 && ((now_seg
== SEG_DATA
)
254 || (now_seg
== S_GET_SEGMENT (symbolP
))))
257 * Select which of the 2 cases this is
259 if (now_seg
!= SEG_DATA
)
262 * New .comm for prev .comm symbol.
263 * If the new size is larger we just
264 * change its value. If the new size
265 * is smaller, we ignore this symbol
267 if (S_GET_VALUE (symbolP
)
268 < ((unsigned) (obstack_next_free (&frags
) - frag_now
->fr_literal
)))
270 S_SET_VALUE (symbolP
,
271 obstack_next_free (&frags
) -
272 frag_now
->fr_literal
);
277 /* It is a .comm/.lcomm being converted to initialized
279 symbolP
->sy_frag
= frag_now
;
281 symbolP
->sy_other
= const_flag
;
283 S_SET_VALUE (symbolP
, obstack_next_free (&frags
) - frag_now
->fr_literal
);
284 S_SET_SEGMENT (symbolP
, now_seg
); /* keep N_EXT bit */
290 as_fatal ("Symbol \"%s\" is already defined as \"%s\"/%d.",
292 segment_name (S_GET_SEGMENT (symbolP
)),
293 S_GET_VALUE (symbolP
));
295 as_fatal ("Symbol \"%s\" is already defined as \"%s\"/%d.%d.%d.",
297 segment_name (S_GET_SEGMENT (symbolP
)),
298 S_GET_OTHER (symbolP
), S_GET_DESC (symbolP
),
299 S_GET_VALUE (symbolP
));
300 #endif /* OBJ_COFF */
302 } /* if the undefined symbol has no value */
306 /* Don't blow up if the definition is the same */
307 if (!(frag_now
== symbolP
->sy_frag
308 && S_GET_VALUE (symbolP
) == obstack_next_free (&frags
) - frag_now
->fr_literal
309 && S_GET_SEGMENT (symbolP
) == now_seg
))
310 as_fatal ("Symbol %s already defined.", sym_name
);
311 } /* if this symbol is not yet defined */
316 symbolP
= symbol_new (sym_name
,
318 (valueT
) (obstack_next_free (&frags
) - frag_now
->fr_literal
),
321 S_SET_OTHER (symbolP
, const_flag
);
324 symbol_table_insert (symbolP
);
325 } /* if we have seen this symbol before */
332 * symbol_table_insert()
334 * Die if we can't insert the symbol.
339 symbol_table_insert (symbolP
)
342 register char *error_string
;
345 know (S_GET_NAME (symbolP
));
347 if (*(error_string
= hash_jam (sy_hash
, S_GET_NAME (symbolP
), (char *) symbolP
)))
349 as_fatal ("Inserting \"%s\" into symbol table failed: %s",
350 S_GET_NAME (symbolP
), error_string
);
352 } /* symbol_table_insert() */
355 * symbol_find_or_make()
357 * If a symbol name does not exist, create it as undefined, and insert
358 * it into the symbol table. Return a pointer to it.
361 symbol_find_or_make (name
)
364 register symbolS
*symbolP
;
366 symbolP
= symbol_find (name
);
370 symbolP
= symbol_make (name
);
372 symbol_table_insert (symbolP
);
373 } /* if symbol wasn't found */
376 } /* symbol_find_or_make() */
384 /* Let the machine description default it, e.g. for register names. */
385 symbolP
= md_undefined_symbol (name
);
389 symbolP
= symbol_new (name
,
393 } /* if md didn't build us a symbol */
396 } /* symbol_make() */
401 * Implement symbol table lookup.
402 * In: A symbol's name as a string: '\0' can't be part of a symbol name.
403 * Out: NULL if the name was not in the symbol table, else the address
404 * of a struct symbol associated with that name.
411 #ifdef STRIP_UNDERSCORE
412 return (symbol_find_base (name
, 1));
413 #else /* STRIP_UNDERSCORE */
414 return (symbol_find_base (name
, 0));
415 #endif /* STRIP_UNDERSCORE */
416 } /* symbol_find() */
419 symbol_find_base (name
, strip_underscore
)
421 int strip_underscore
;
423 if (strip_underscore
&& *name
== '_')
425 return ((symbolS
*) hash_find (sy_hash
, name
));
429 * Once upon a time, symbols were kept in a singly linked list. At
430 * least coff needs to be able to rearrange them from time to time, for
431 * which a doubly linked list is much more convenient. Loic did these
432 * as macros which seemed dangerous to me so they're now functions.
436 /* Link symbol ADDME after symbol TARGET in the chain. */
438 symbol_append (addme
, target
, rootPP
, lastPP
)
446 know (*rootPP
== NULL
);
447 know (*lastPP
== NULL
);
451 } /* if the list is empty */
453 if (target
->sy_next
!= NULL
)
455 #ifdef SYMBOLS_NEED_BACKPOINTERS
456 target
->sy_next
->sy_previous
= addme
;
457 #endif /* SYMBOLS_NEED_BACKPOINTERS */
461 know (*lastPP
== target
);
463 } /* if we have a next */
465 addme
->sy_next
= target
->sy_next
;
466 target
->sy_next
= addme
;
468 #ifdef SYMBOLS_NEED_BACKPOINTERS
469 addme
->sy_previous
= target
;
470 #endif /* SYMBOLS_NEED_BACKPOINTERS */
473 /* verify_symbol_chain(*rootPP, *lastPP); */
477 } /* symbol_append() */
479 #ifdef SYMBOLS_NEED_BACKPOINTERS
480 /* Remove SYMBOLP from the list. */
482 symbol_remove (symbolP
, rootPP
, lastPP
)
487 if (symbolP
== *rootPP
)
489 *rootPP
= symbolP
->sy_next
;
490 } /* if it was the root */
492 if (symbolP
== *lastPP
)
494 *lastPP
= symbolP
->sy_previous
;
495 } /* if it was the tail */
497 if (symbolP
->sy_next
!= NULL
)
499 symbolP
->sy_next
->sy_previous
= symbolP
->sy_previous
;
502 if (symbolP
->sy_previous
!= NULL
)
504 symbolP
->sy_previous
->sy_next
= symbolP
->sy_next
;
508 verify_symbol_chain (*rootPP
, *lastPP
);
512 } /* symbol_remove() */
514 /* Set the chain pointers of SYMBOL to null. */
516 symbol_clear_list_pointers (symbolP
)
519 symbolP
->sy_next
= NULL
;
520 symbolP
->sy_previous
= NULL
;
521 } /* symbol_clear_list_pointers() */
523 /* Link symbol ADDME before symbol TARGET in the chain. */
525 symbol_insert (addme
, target
, rootPP
, lastPP
)
531 if (target
->sy_previous
!= NULL
)
533 target
->sy_previous
->sy_next
= addme
;
537 know (*rootPP
== target
);
541 addme
->sy_previous
= target
->sy_previous
;
542 target
->sy_previous
= addme
;
543 addme
->sy_next
= target
;
546 verify_symbol_chain (*rootPP
, *lastPP
);
550 } /* symbol_insert() */
552 #endif /* SYMBOLS_NEED_BACKPOINTERS */
555 verify_symbol_chain (rootP
, lastP
)
559 symbolS
*symbolP
= rootP
;
566 for (; symbol_next (symbolP
) != NULL
; symbolP
= symbol_next (symbolP
))
568 #ifdef SYMBOLS_NEED_BACKPOINTERS
569 /*$if (symbolP->sy_previous) {
570 know(symbolP->sy_previous->sy_next == symbolP);
572 know(symbolP == rootP);
573 }$*//* both directions */
574 know (symbolP
->sy_next
->sy_previous
== symbolP
);
575 #else /* SYMBOLS_NEED_BACKPOINTERS */
577 #endif /* SYMBOLS_NEED_BACKPOINTERS */
578 } /* verify pointers */
580 know (lastP
== symbolP
);
583 } /* verify_symbol_chain() */
586 #ifdef LOCAL_LABELS_DOLLAR
588 /* Dollar labels look like a number followed by a dollar sign. Eg, "42$".
589 They are *really* local. That is, they go out of scope whenever we see a
590 label that isn't local. Also, like fb labels, there can be multiple
591 instances of a dollar label. Therefor, we name encode each instance with
592 the instance number, keep a list of defined symbols separate from the real
593 symbol table, and we treat these buggers as a sparse array. */
595 static long *dollar_labels
= NULL
;
596 static long *dollar_label_instances
= NULL
;
597 static char *dollar_label_defines
= NULL
;
598 static long dollar_label_count
= 0;
599 static long dollar_label_max
= 0;
602 dollar_label_defined (label
)
607 know ((dollar_labels
!= NULL
) || (dollar_label_count
== 0));
609 for (i
= dollar_labels
; i
< dollar_labels
+ dollar_label_count
; ++i
)
613 return (dollar_label_defines
[i
- dollar_labels
]);
615 } /* look for label */
617 /* if we get here, label isn't defined */
619 } /* dollar_label_defined() */
622 dollar_label_instance (label
)
627 know ((dollar_labels
!= NULL
) || (dollar_label_count
== 0));
629 for (i
= dollar_labels
; i
< dollar_labels
+ dollar_label_count
; ++i
)
633 return (dollar_label_instances
[i
- dollar_labels
]);
635 } /* look for (the union :-) label */
637 /* if we get here, we haven't seen the label before, therefor it's instance
640 } /* dollar_label_instance() */
643 dollar_label_clear ()
645 memset (dollar_label_defines
, '\0', dollar_label_count
);
647 } /* clear_dollar_labels() */
649 #define DOLLAR_LABEL_BUMP_BY 10
652 define_dollar_label (label
)
657 for (i
= dollar_labels
; i
< dollar_labels
+ dollar_label_count
; ++i
)
661 ++dollar_label_instances
[i
- dollar_labels
];
662 dollar_label_defines
[i
- dollar_labels
] = 1;
664 } /* if we find it */
665 } /* for each existing label */
667 /* if we get to here, we don't have label listed yet. */
669 if (dollar_labels
== NULL
)
671 dollar_labels
= (long *) xmalloc (DOLLAR_LABEL_BUMP_BY
* sizeof (long));
672 dollar_label_instances
= (long *) xmalloc (DOLLAR_LABEL_BUMP_BY
* sizeof (long));
673 dollar_label_defines
= xmalloc (DOLLAR_LABEL_BUMP_BY
);
674 dollar_label_max
= DOLLAR_LABEL_BUMP_BY
;
675 dollar_label_count
= 0;
678 else if (dollar_label_count
== dollar_label_max
)
680 dollar_label_max
+= DOLLAR_LABEL_BUMP_BY
;
681 dollar_labels
= (long *) xrealloc ((char *) dollar_labels
,
682 dollar_label_max
* sizeof (long));
683 dollar_label_instances
= (long *) xrealloc ((char *) dollar_label_instances
,
684 dollar_label_max
* sizeof (long));
685 dollar_label_defines
= xrealloc (dollar_label_defines
, dollar_label_max
);
686 } /* if we needed to grow */
688 dollar_labels
[dollar_label_count
] = label
;
689 dollar_label_instances
[dollar_label_count
] = 1;
690 dollar_label_defines
[dollar_label_count
] = 1;
691 ++dollar_label_count
;
693 } /* define_dollar_label() */
696 * dollar_label_name()
698 * Caller must copy returned name: we re-use the area for the next name.
700 * The mth occurence of label n: is turned into the symbol "Ln^Am" where
701 * n is the label number and m is the instance number. "L" makes it a label discarded
702 * unless debugging and "^A"('\1') ensures no ordinary symbol SHOULD get the
703 * same name as a local label symbol. The first "4:" is "L4^A1" - the m
704 * numbers begin at 1.
706 * fb labels get the same treatment, except that ^B is used in place of ^A.
709 char * /* Return local label name. */
710 dollar_label_name (n
, augend
)
711 register long n
; /* we just saw "n$:" : n a number */
712 register int augend
; /* 0 for current instance, 1 for new instance */
715 /* Returned to caller, then copied. used for created names ("4f") */
716 static char symbol_name_build
[24];
719 char symbol_name_temporary
[20]; /* build up a number, BACKWARDS */
722 know (augend
== 0 || augend
== 1);
723 p
= symbol_name_build
;
726 /* Next code just does sprintf( {}, "%d", n); */
728 q
= symbol_name_temporary
;
729 for (*q
++ = 0, i
= n
; i
; ++q
)
734 while ((*p
= *--q
) != '\0')
739 /* instance number */
740 q
= symbol_name_temporary
;
741 for (*q
++ = 0, i
= dollar_label_instance (n
) + augend
; i
; ++q
)
746 while ((*p
++ = *--q
) != '\0');;
748 /* The label, as a '\0' ended string, starts at symbol_name_build. */
749 return (symbol_name_build
);
750 } /* dollar_label_name() */
752 #endif /* LOCAL_LABELS_DOLLAR */
754 #ifdef LOCAL_LABELS_FB
757 * Sombody else's idea of local labels. They are made by "n:" where n
758 * is any decimal digit. Refer to them with
759 * "nb" for previous (backward) n:
760 * or "nf" for next (forward) n:.
762 * We do a little better and let n be any number, not just a single digit, but
763 * since the other guy's assembler only does ten, we treat the first ten
766 * Like someone else's assembler, we have one set of local label counters for
767 * entire assembly, not one set per (sub)segment like in most assemblers. This
768 * implies that one can refer to a label in another segment, and indeed some
769 * crufty compilers have done just that.
771 * Since there could be a LOT of these things, treat them as a sparse array.
774 #define FB_LABEL_SPECIAL (10)
776 static long fb_low_counter
[FB_LABEL_SPECIAL
];
777 static long *fb_labels
;
778 static long *fb_label_instances
;
779 static long fb_label_count
= 0;
780 static long fb_label_max
= 0;
782 /* this must be more than FB_LABEL_SPECIAL */
783 #define FB_LABEL_BUMP_BY (FB_LABEL_SPECIAL + 6)
788 memset ((void *) fb_low_counter
, '\0', sizeof (fb_low_counter
));
789 } /* fb_label_init() */
791 /* add one to the instance number of this fb label */
793 fb_label_instance_inc (label
)
798 if (label
< FB_LABEL_SPECIAL
)
800 ++fb_low_counter
[label
];
804 for (i
= fb_labels
+ FB_LABEL_SPECIAL
; i
< fb_labels
+ fb_label_count
; ++i
)
808 ++fb_label_instances
[i
- fb_labels
];
810 } /* if we find it */
811 } /* for each existing label */
813 /* if we get to here, we don't have label listed yet. */
815 if (fb_labels
== NULL
)
817 fb_labels
= (long *) xmalloc (FB_LABEL_BUMP_BY
* sizeof (long));
818 fb_label_instances
= (long *) xmalloc (FB_LABEL_BUMP_BY
* sizeof (long));
819 fb_label_max
= FB_LABEL_BUMP_BY
;
820 fb_label_count
= FB_LABEL_SPECIAL
;
823 else if (fb_label_count
== fb_label_max
)
825 fb_label_max
+= FB_LABEL_BUMP_BY
;
826 fb_labels
= (long *) xrealloc ((char *) fb_labels
,
827 fb_label_max
* sizeof (long));
828 fb_label_instances
= (long *) xrealloc ((char *) fb_label_instances
,
829 fb_label_max
* sizeof (long));
830 } /* if we needed to grow */
832 fb_labels
[fb_label_count
] = label
;
833 fb_label_instances
[fb_label_count
] = 1;
836 } /* fb_label_instance_inc() */
839 fb_label_instance (label
)
844 if (label
< FB_LABEL_SPECIAL
)
846 return (fb_low_counter
[label
]);
849 for (i
= fb_labels
+ FB_LABEL_SPECIAL
; i
< fb_labels
+ fb_label_count
; ++i
)
853 return (fb_label_instances
[i
- fb_labels
]);
854 } /* if we find it */
855 } /* for each existing label */
859 } /* fb_label_instance() */
864 * Caller must copy returned name: we re-use the area for the next name.
866 * The mth occurence of label n: is turned into the symbol "Ln^Bm" where
867 * n is the label number and m is the instance number. "L" makes it a label discarded
868 * unless debugging and "^B"('\2') ensures no ordinary symbol SHOULD get the
869 * same name as a local label symbol. The first "4:" is "L4^B1" - the m
870 * numbers begin at 1.
872 * dollar labels get the same treatment, except that ^A is used in place of ^B.
875 char * /* Return local label name. */
876 fb_label_name (n
, augend
)
877 long n
; /* we just saw "n:", "nf" or "nb" : n a number */
878 long augend
; /* 0 for nb, 1 for n:, nf */
881 /* Returned to caller, then copied. used for created names ("4f") */
882 static char symbol_name_build
[24];
885 char symbol_name_temporary
[20]; /* build up a number, BACKWARDS */
888 know (augend
== 0 || augend
== 1);
889 p
= symbol_name_build
;
892 /* Next code just does sprintf( {}, "%d", n); */
894 q
= symbol_name_temporary
;
895 for (*q
++ = 0, i
= n
; i
; ++q
)
900 while ((*p
= *--q
) != '\0')
905 /* instance number */
906 q
= symbol_name_temporary
;
907 for (*q
++ = 0, i
= fb_label_instance (n
) + augend
; i
; ++q
)
912 while ((*p
++ = *--q
) != '\0');;
914 /* The label, as a '\0' ended string, starts at symbol_name_build. */
915 return (symbol_name_build
);
916 } /* fb_label_name() */
918 #endif /* LOCAL_LABELS_FB */
922 * decode name that may have been generated by foo_label_name() above. If
923 * the name wasn't generated by foo_label_name(), then return it unaltered.
924 * This is used for error messages.
928 decode_local_label_name (s
)
936 const char *message_format
= "\"%d\" (instance number %d of a %s label)";
941 for (label_number
= 0, p
= s
+ 1; isdigit (*p
); ++p
)
943 label_number
= (10 * label_number
) + *p
- '0';
959 for (instance_number
= 0, p
= s
+ 1; isdigit (*p
); ++p
)
961 instance_number
= (10 * instance_number
) + *p
- '0';
964 symbol_decode
= obstack_alloc (¬es
, strlen (message_format
) + 30);
965 (void) sprintf (symbol_decode
, message_format
, label_number
,
966 instance_number
, type
);
968 return (symbol_decode
);
969 } /* decode_local_label_name() */
971 /* end of symbols.c */
This page took 0.048389 seconds and 4 git commands to generate.