1 /* listing.c - mainting assembly listings
2 Copyright 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
4 Free Software Foundation, Inc.
6 This file is part of GAS, the GNU Assembler.
8 GAS is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2, or (at your option)
13 GAS is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with GAS; see the file COPYING. If not, write to the Free
20 Software Foundation, 59 Temple Place - Suite 330, Boston, MA
24 Contributed by Steve Chamberlain <sac@cygnus.com>
26 A listing page looks like:
28 LISTING_HEADER sourcefilename pagenumber
31 linenumber address data source
32 linenumber address data source
33 linenumber address data source
34 linenumber address data source
36 If not overridden, the listing commands are:
39 Put "stuff" onto the title line
41 Put stuff onto the subtitle line
43 If these commands come within 10 lines of the top of the page, they
44 will affect the page they are on, as well as any subsequent page
49 Increment the enable listing counter
51 Decrement the enable listing counter
54 Set the paper size to X wide and Y high. Setting a psize Y of
55 zero will suppress form feeds except where demanded by .eject
57 If the counter goes below zero, listing is suppressed.
59 Listings are a maintained by read calling various listing_<foo>
60 functions. What happens most is that the macro NO_LISTING is not
61 defined (from the Makefile), then the macro LISTING_NEWLINE expands
62 into a call to listing_newline. The call is done from read.c, every
63 time it sees a newline, and -l is on the command line.
65 The function listing_newline remembers the frag associated with the
66 newline, and creates a new frag - note that this is wasteful, but not
67 a big deal, since listing slows things down a lot anyway. The
68 function also rememebers when the filename changes.
70 When all the input has finished, and gas has had a chance to settle
71 down, the listing is output. This is done by running down the list of
72 frag/source file records, and opening the files as needed and printing
73 out the bytes and chars associated with them.
75 The only things which the architecture can change about the listing
76 are defined in these macros:
78 LISTING_HEADER The name of the architecture
79 LISTING_WORD_SIZE The make of the number of bytes in a word, this determines
80 the clumping of the output data. eg a value of
81 2 makes words look like 1234 5678, whilst 1
82 would make the same value look like 12 34 56
84 LISTING_LHS_WIDTH Number of words of above size for the lhs
86 LISTING_LHS_WIDTH_SECOND Number of words for the data on the lhs
89 LISTING_LHS_CONT_LINES Max number of lines to use up for a continutation
90 LISTING_RHS_WIDTH Number of chars from the input file to print
96 #include "safe-ctype.h"
97 #include "input-file.h"
102 #ifndef LISTING_HEADER
103 #define LISTING_HEADER "GAS LISTING"
105 #ifndef LISTING_WORD_SIZE
106 #define LISTING_WORD_SIZE 4
108 #ifndef LISTING_LHS_WIDTH
109 #define LISTING_LHS_WIDTH ((LISTING_WORD_SIZE) > 4 ? 1 : 4 / (LISTING_WORD_SIZE))
111 #ifndef LISTING_LHS_WIDTH_SECOND
112 #define LISTING_LHS_WIDTH_SECOND LISTING_LHS_WIDTH
114 #ifndef LISTING_RHS_WIDTH
115 #define LISTING_RHS_WIDTH 100
117 #ifndef LISTING_LHS_CONT_LINES
118 #define LISTING_LHS_CONT_LINES 4
121 /* This structure remembers which .s were used. */
122 typedef struct file_info_struct
{
123 struct file_info_struct
* next
;
126 unsigned int linenum
;
130 /* This structure rememebrs which line from which file goes into which
132 struct list_info_struct
{
133 /* Frag which this line of source is nearest to. */
136 /* The actual line in the source file. */
138 /* Pointer to the file info struct for the file which this line
140 file_info_type
*file
;
142 /* The expanded text of any macro that may have been executing. */
146 struct list_info_struct
*next
;
148 /* Pointer to the file info struct for the high level language
149 source line that belongs here. */
150 file_info_type
*hll_file
;
151 /* High level language source line. */
152 unsigned int hll_line
;
154 /* Pointer to any error message associated with this line. */
168 /* Nonzero if this line is to be omitted because it contains
169 debugging information. This can become a flags field if we come
170 up with more information to store here. */
174 typedef struct list_info_struct list_info_type
;
176 int listing_lhs_width
= LISTING_LHS_WIDTH
;
177 int listing_lhs_width_second
= LISTING_LHS_WIDTH_SECOND
;
178 int listing_lhs_cont_lines
= LISTING_LHS_CONT_LINES
;
179 int listing_rhs_width
= LISTING_RHS_WIDTH
;
181 struct list_info_struct
* listing_tail
;
183 static file_info_type
* file_info_head
;
184 static file_info_type
* last_open_file_info
;
185 static FILE * last_open_file
;
186 static struct list_info_struct
* head
;
187 static int paper_width
= 200;
188 static int paper_height
= 60;
192 /* File to output listings to. */
193 static FILE *list_file
;
195 /* This static array is used to keep the text of data to be printed
196 before the start of the line. */
199 (((LISTING_WORD_SIZE * 2) + 1) * listing_lhs_width \
200 + ((((LISTING_WORD_SIZE * 2) + 1) * listing_lhs_width_second) \
201 * listing_lhs_cont_lines) \
204 static char *data_buffer
;
207 static void listing_message
PARAMS ((const char *name
, const char *message
));
208 static file_info_type
*file_info
PARAMS ((const char *file_name
));
209 static void new_frag
PARAMS ((void));
210 static char *buffer_line
PARAMS ((file_info_type
*file
,
211 char *line
, unsigned int size
));
212 static void listing_page
PARAMS ((list_info_type
*list
));
213 static unsigned int calc_hex
PARAMS ((list_info_type
*list
));
214 static void print_lines
PARAMS ((list_info_type
*, unsigned int,
215 char *, unsigned int));
216 static void list_symbol_table
PARAMS ((void));
217 static void print_source
PARAMS ((file_info_type
*current_file
,
218 list_info_type
*list
,
220 unsigned int width
));
221 static int debugging_pseudo
PARAMS ((list_info_type
*, const char *));
222 static void listing_listing
PARAMS ((char *name
));
225 listing_message (name
, message
)
229 if (listing_tail
!= (list_info_type
*) NULL
)
231 unsigned int l
= strlen (name
) + strlen (message
) + 1;
232 char *n
= (char *) xmalloc (l
);
235 listing_tail
->message
= n
;
240 listing_warning (message
)
243 listing_message (_("Warning:"), message
);
247 listing_error (message
)
250 listing_message (_("Error:"), message
);
253 static file_info_type
*
254 file_info (file_name
)
255 const char *file_name
;
257 /* Find an entry with this file name. */
258 file_info_type
*p
= file_info_head
;
260 while (p
!= (file_info_type
*) NULL
)
262 if (strcmp (p
->filename
, file_name
) == 0)
267 /* Make new entry. */
269 p
= (file_info_type
*) xmalloc (sizeof (file_info_type
));
270 p
->next
= file_info_head
;
272 p
->filename
= xstrdup (file_name
);
284 frag_wane (frag_now
);
295 static unsigned int last_line
= 0xffff;
296 static char *last_file
= NULL
;
297 list_info_type
*new = NULL
;
302 if (now_seg
== absolute_section
)
306 /* In ELF, anything in a section beginning with .debug or .line is
307 considered to be debugging information. This includes the
308 statement which switches us into the debugging section, which we
309 can only set after we are already in the debugging section. */
310 if ((listing
& LISTING_NODEBUG
) != 0
311 && listing_tail
!= NULL
312 && ! listing_tail
->debugging
)
316 segname
= segment_name (now_seg
);
317 if (strncmp (segname
, ".debug", sizeof ".debug" - 1) == 0
318 || strncmp (segname
, ".line", sizeof ".line" - 1) == 0)
319 listing_tail
->debugging
= 1;
323 as_where (&file
, &line
);
326 if (line
== last_line
327 && !(last_file
&& file
&& strcmp (file
, last_file
)))
330 new = (list_info_type
*) xmalloc (sizeof (list_info_type
));
332 /* Detect if we are reading from stdin by examining the file
333 name returned by as_where().
335 [FIXME: We rely upon the name in the strcmp below being the
336 same as the one used by input_scrub_new_file(), if that is
337 not true, then this code will fail].
339 If we are reading from stdin, then we need to save each input
340 line here (assuming of course that we actually have a line of
341 input to read), so that it can be displayed in the listing
342 that is produced at the end of the assembly. */
343 if (strcmp (file
, _("{standard input}")) == 0
344 && input_line_pointer
!= NULL
)
350 for (copy
= input_line_pointer
- 1;
352 || (! is_end_of_line
[(unsigned char) *copy
]));
354 if (*copy
== '"' && copy
[-1] != '\\')
355 seen_quote
= ! seen_quote
;
357 len
= (copy
- input_line_pointer
) + 2;
359 copy
= xmalloc (len
);
363 char *src
= input_line_pointer
- 1;
368 unsigned char c
= *src
++;
370 /* Omit control characters in the listing. */
378 new->line_contents
= copy
;
381 new->line_contents
= NULL
;
385 new = (list_info_type
*) xmalloc (sizeof (list_info_type
));
386 new->line_contents
= ps
;
395 listing_tail
->next
= new;
401 new->frag
= frag_now
;
403 new->file
= file_info (file
);
404 new->next
= (list_info_type
*) NULL
;
405 new->message
= (char *) NULL
;
406 new->edict
= EDICT_NONE
;
407 new->hll_file
= (file_info_type
*) NULL
;
414 /* In ELF, anything in a section beginning with .debug or .line is
415 considered to be debugging information. */
416 if ((listing
& LISTING_NODEBUG
) != 0)
420 segname
= segment_name (now_seg
);
421 if (strncmp (segname
, ".debug", sizeof ".debug" - 1) == 0
422 || strncmp (segname
, ".line", sizeof ".line" - 1) == 0)
428 /* Attach all current frags to the previous line instead of the
429 current line. This is called by the MIPS backend when it discovers
430 that it needs to add some NOP instructions; the added NOP
431 instructions should go with the instruction that has the delay, not
432 with the new instruction. */
440 if (head
== (list_info_type
*) NULL
441 || head
== listing_tail
)
446 for (l
= head
; l
->next
!= listing_tail
; l
= l
->next
)
449 for (f
= frchain_now
->frch_root
; f
!= (fragS
*) NULL
; f
= f
->fr_next
)
450 if (f
->line
== listing_tail
)
453 listing_tail
->frag
= frag_now
;
457 /* This function returns the next source line from the file supplied,
458 truncated to size. It appends a fake line to the end of each input
462 buffer_line (file
, line
, size
)
463 file_info_type
*file
;
467 unsigned int count
= 0;
472 /* If we couldn't open the file, return an empty line. */
476 /* Check the cache and see if we last used this file. */
477 if (!last_open_file_info
|| file
!= last_open_file_info
)
481 last_open_file_info
->pos
= ftell (last_open_file
);
482 fclose (last_open_file
);
485 last_open_file_info
= file
;
486 last_open_file
= fopen (file
->filename
, FOPEN_RT
);
487 if (last_open_file
== NULL
)
493 /* Seek to where we were last time this file was open. */
495 fseek (last_open_file
, file
->pos
, SEEK_SET
);
498 c
= fgetc (last_open_file
);
500 /* Leave room for null. */
503 while (c
!= EOF
&& c
!= '\n')
509 c
= fgetc (last_open_file
);
515 if (count
+ 2 < size
)
527 static const char *fn
;
529 static unsigned int eject
; /* Eject pending */
530 static unsigned int page
; /* Current page number */
531 static char *title
; /* Current title */
532 static char *subtitle
; /* Current subtitle */
533 static unsigned int on_page
; /* Number of lines printed on current page */
537 list_info_type
*list
;
539 /* Grope around, see if we can see a title or subtitle edict coming up
540 soon. (we look down 10 lines of the page and see if it's there) */
541 if ((eject
|| (on_page
>= (unsigned int) paper_height
))
542 && paper_height
!= 0)
546 int had_subtitle
= 0;
550 while (c
!= 0 && list
)
552 if (list
->edict
== EDICT_SBTTL
&& !had_subtitle
)
555 subtitle
= list
->edict_arg
;
557 if (list
->edict
== EDICT_TITLE
&& !had_title
)
560 title
= list
->edict_arg
;
568 fprintf (list_file
, "\f");
571 fprintf (list_file
, "%s %s \t\t\tpage %d\n", LISTING_HEADER
, fn
, page
);
572 fprintf (list_file
, "%s\n", title
);
573 fprintf (list_file
, "%s\n", subtitle
);
581 list_info_type
*list
;
583 int data_buffer_size
;
584 list_info_type
*first
= list
;
585 unsigned int address
= ~(unsigned int) 0;
588 unsigned int octet_in_frag
;
590 /* Find first frag which says it belongs to this line. */
592 while (frag
&& frag
->line
!= list
)
593 frag
= frag
->fr_next
;
597 data_buffer_size
= 0;
599 /* Dump all the frags which belong to this line. */
600 while (frag_ptr
!= (fragS
*) NULL
&& frag_ptr
->line
== first
)
602 /* Print as many bytes from the fixed part as is sensible. */
604 while ((offsetT
) octet_in_frag
< frag_ptr
->fr_fix
605 && data_buffer_size
< MAX_BYTES
- 3)
607 if (address
== ~(unsigned int) 0)
609 address
= frag_ptr
->fr_address
/ OCTETS_PER_BYTE
;
612 sprintf (data_buffer
+ data_buffer_size
,
614 (frag_ptr
->fr_literal
[octet_in_frag
]) & 0xff);
615 data_buffer_size
+= 2;
618 if (frag_ptr
->fr_type
== rs_fill
)
620 unsigned int var_rep_max
= octet_in_frag
;
621 unsigned int var_rep_idx
= octet_in_frag
;
623 /* Print as many bytes from the variable part as is sensible. */
624 while (((offsetT
) octet_in_frag
625 < (frag_ptr
->fr_fix
+ frag_ptr
->fr_var
* frag_ptr
->fr_offset
))
626 && data_buffer_size
< MAX_BYTES
- 3)
628 if (address
== ~(unsigned int) 0)
630 address
= frag_ptr
->fr_address
/ OCTETS_PER_BYTE
;
632 sprintf (data_buffer
+ data_buffer_size
,
634 (frag_ptr
->fr_literal
[var_rep_idx
]) & 0xff);
636 data_buffer
[data_buffer_size
++] = '*';
637 data_buffer
[data_buffer_size
++] = '*';
639 data_buffer_size
+= 2;
644 if ((offsetT
) var_rep_idx
>= frag_ptr
->fr_fix
+ frag_ptr
->fr_var
)
645 var_rep_idx
= var_rep_max
;
649 frag_ptr
= frag_ptr
->fr_next
;
651 data_buffer
[data_buffer_size
] = '\0';
656 print_lines (list
, lineno
, string
, address
)
657 list_info_type
*list
;
660 unsigned int address
;
665 unsigned int octet_in_word
= 0;
666 char *src
= data_buffer
;
669 /* Print the stuff on the first line. */
671 nchars
= (LISTING_WORD_SIZE
* 2 + 1) * listing_lhs_width
;
673 /* Print the hex for the first line. */
674 if (address
== ~(unsigned int) 0)
676 fprintf (list_file
, "% 4d ", lineno
);
677 for (idx
= 0; idx
< nchars
; idx
++)
678 fprintf (list_file
, " ");
680 fprintf (list_file
, "\t%s\n", string
? string
: "");
690 fprintf (list_file
, "% 4d ???? ", lineno
);
692 fprintf (list_file
, "% 4d %04x ", lineno
, address
);
694 /* And the data to go along with it. */
697 while (src
[cur
] && idx
< nchars
)
701 fprintf (list_file
, "%c%c", src
[offset
], src
[offset
+ 1]);
705 if (octet_in_word
== LISTING_WORD_SIZE
)
707 fprintf (list_file
, " ");
715 for (; idx
< nchars
; idx
++)
716 fprintf (list_file
, " ");
718 fprintf (list_file
, "\t%s\n", string
? string
: "");
724 fprintf (list_file
, "**** %s\n", list
->message
);
730 lines
< (unsigned int) listing_lhs_cont_lines
734 nchars
= ((LISTING_WORD_SIZE
* 2) + 1) * listing_lhs_width_second
- 1;
737 /* Print any more lines of data, but more compactly. */
738 fprintf (list_file
, "% 4d ", lineno
);
740 while (src
[cur
] && idx
< nchars
)
744 fprintf (list_file
, "%c%c", src
[offset
], src
[offset
+ 1]);
749 if (octet_in_word
== LISTING_WORD_SIZE
)
751 fprintf (list_file
, " ");
757 fprintf (list_file
, "\n");
766 extern symbolS
*symbol_rootP
;
773 for (ptr
= symbol_rootP
; ptr
!= (symbolS
*) NULL
; ptr
= symbol_next (ptr
))
775 if (SEG_NORMAL (S_GET_SEGMENT (ptr
))
776 || S_GET_SEGMENT (ptr
) == absolute_section
)
779 /* Don't report section symbols. They are not interesting. */
780 if (symbol_section_p (ptr
))
783 if (S_GET_NAME (ptr
))
785 char buf
[30], fmt
[8];
786 valueT val
= S_GET_VALUE (ptr
);
788 /* @@ Note that this is dependent on the compilation options,
789 not solely on the target characteristics. */
790 if (sizeof (val
) == 4 && sizeof (int) == 4)
791 sprintf (buf
, "%08lx", (unsigned long) val
);
792 else if (sizeof (val
) <= sizeof (unsigned long))
794 sprintf (fmt
, "%%0%lulx",
795 (unsigned long) (sizeof (val
) * 2));
796 sprintf (buf
, fmt
, (unsigned long) val
);
799 else if (sizeof (val
) > 4)
800 sprintf_vma (buf
, val
);
807 fprintf (list_file
, "DEFINED SYMBOLS\n");
812 if (symbol_get_frag (ptr
) && symbol_get_frag (ptr
)->line
)
814 fprintf (list_file
, "%20s:%-5d %s:%s %s\n",
815 symbol_get_frag (ptr
)->line
->file
->filename
,
816 symbol_get_frag (ptr
)->line
->line
,
817 segment_name (S_GET_SEGMENT (ptr
)),
818 buf
, S_GET_NAME (ptr
));
822 fprintf (list_file
, "%33s:%s %s\n",
823 segment_name (S_GET_SEGMENT (ptr
)),
824 buf
, S_GET_NAME (ptr
));
835 fprintf (list_file
, "NO DEFINED SYMBOLS\n");
838 fprintf (list_file
, "\n");
844 for (ptr
= symbol_rootP
; ptr
!= (symbolS
*) NULL
; ptr
= symbol_next (ptr
))
846 if (S_GET_NAME (ptr
) && strlen (S_GET_NAME (ptr
)) != 0)
848 if (S_GET_SEGMENT (ptr
) == undefined_section
)
853 fprintf (list_file
, "UNDEFINED SYMBOLS\n");
857 fprintf (list_file
, "%s\n", S_GET_NAME (ptr
));
865 fprintf (list_file
, "NO UNDEFINED SYMBOLS\n");
872 print_source (current_file
, list
, buffer
, width
)
873 file_info_type
*current_file
;
874 list_info_type
*list
;
878 if (!current_file
->at_end
)
880 while (current_file
->linenum
< list
->hll_line
881 && !current_file
->at_end
)
883 char *p
= buffer_line (current_file
, buffer
, width
);
884 fprintf (list_file
, "%4u:%-13s **** %s\n", current_file
->linenum
,
885 current_file
->filename
, p
);
892 /* Sometimes the user doesn't want to be bothered by the debugging
893 records inserted by the compiler, see if the line is suspicious. */
896 debugging_pseudo (list
, line
)
897 list_info_type
*list
;
909 was_debug
= in_debug
;
912 while (ISSPACE (*line
))
918 /* The ELF compiler sometimes emits blank lines after switching
919 out of a debugging section. If the next line drops us back
920 into debugging information, then don't print the blank line.
921 This is a hack for a particular compiler behaviour, not a
925 && list
->next
!= NULL
926 && list
->next
->debugging
)
938 if (strncmp (line
, "def", 3) == 0)
940 if (strncmp (line
, "val", 3) == 0)
942 if (strncmp (line
, "scl", 3) == 0)
944 if (strncmp (line
, "line", 4) == 0)
946 if (strncmp (line
, "endef", 5) == 0)
948 if (strncmp (line
, "ln", 2) == 0)
950 if (strncmp (line
, "type", 4) == 0)
952 if (strncmp (line
, "size", 4) == 0)
954 if (strncmp (line
, "dim", 3) == 0)
956 if (strncmp (line
, "tag", 3) == 0)
959 if (strncmp (line
, "stabs", 5) == 0)
961 if (strncmp (line
, "stabn", 5) == 0)
968 listing_listing (name
)
969 char *name ATTRIBUTE_UNUSED
;
971 list_info_type
*list
= head
;
972 file_info_type
*current_hll_file
= (file_info_type
*) NULL
;
976 int show_listing
= 1;
979 buffer
= xmalloc (listing_rhs_width
);
980 data_buffer
= xmalloc (MAX_BYTES
);
984 while (list
!= (list_info_type
*) NULL
&& 0)
987 list
->frag
= list
->next
->frag
;
996 unsigned int list_line
;
998 width
= listing_rhs_width
> paper_width
? paper_width
:
1001 list_line
= list
->line
;
1002 switch (list
->edict
)
1005 /* Skip all lines up to the current. */
1011 case EDICT_NOLIST_NEXT
:
1012 if (show_listing
== 0)
1020 title
= list
->edict_arg
;
1023 subtitle
= list
->edict_arg
;
1029 if (show_listing
<= 0)
1031 while (list
->file
->linenum
< list_line
1032 && !list
->file
->at_end
)
1033 p
= buffer_line (list
->file
, buffer
, width
);
1036 if (list
->edict
== EDICT_LIST
1037 || (list
->edict
== EDICT_NOLIST_NEXT
&& show_listing
== 0))
1039 /* Enable listing for the single line that caused the enable. */
1044 if (show_listing
> 0)
1046 /* Scan down the list and print all the stuff which can be done
1047 with this line (or lines). */
1052 current_hll_file
= list
->hll_file
;
1055 if (current_hll_file
&& list
->hll_line
&& (listing
& LISTING_HLL
))
1057 print_source (current_hll_file
, list
, buffer
, width
);
1060 if (list
->line_contents
)
1062 if (!((listing
& LISTING_NODEBUG
)
1063 && debugging_pseudo (list
, list
->line_contents
)))
1066 list
->file
->linenum
== 0 ? list
->line
: list
->file
->linenum
,
1067 list
->line_contents
, calc_hex (list
));
1069 free (list
->line_contents
);
1070 list
->line_contents
= NULL
;
1074 while (list
->file
->linenum
< list_line
1075 && !list
->file
->at_end
)
1077 unsigned int address
;
1079 p
= buffer_line (list
->file
, buffer
, width
);
1081 if (list
->file
->linenum
< list_line
)
1082 address
= ~(unsigned int) 0;
1084 address
= calc_hex (list
);
1086 if (!((listing
& LISTING_NODEBUG
)
1087 && debugging_pseudo (list
, p
)))
1088 print_lines (list
, list
->file
->linenum
, p
, address
);
1092 if (list
->edict
== EDICT_EJECT
)
1098 if (list
->edict
== EDICT_NOLIST_NEXT
&& show_listing
== 1)
1110 listing_print (name
)
1125 list_file
= fopen (name
, FOPEN_WT
);
1126 if (list_file
!= NULL
)
1130 as_perror (_("can't open list file: %s"), name
);
1136 if (listing
& LISTING_NOFORM
)
1141 if (listing
& LISTING_LISTING
)
1143 listing_listing (name
);
1146 if (listing
& LISTING_SYMBOLS
)
1148 list_symbol_table ();
1153 if (fclose (list_file
) == EOF
)
1154 as_perror (_("error closing list file: %s"), name
);
1159 fclose (last_open_file
);
1171 listing_eject (ignore
)
1172 int ignore ATTRIBUTE_UNUSED
;
1175 listing_tail
->edict
= EDICT_EJECT
;
1179 listing_flags (ignore
)
1180 int ignore ATTRIBUTE_UNUSED
;
1182 while ((*input_line_pointer
++) && (*input_line_pointer
!= '\n'))
1183 input_line_pointer
++;
1187 /* Turn listing on or off. An argument of 0 means to turn off
1188 listing. An argument of 1 means to turn on listing. An argument
1189 of 2 means to turn off listing, but as of the next line; that is,
1190 the current line should be listed, but the next line should not. */
1201 if (listing_tail
->edict
== EDICT_LIST
)
1202 listing_tail
->edict
= EDICT_NONE
;
1204 listing_tail
->edict
= EDICT_NOLIST
;
1207 if (listing_tail
->edict
== EDICT_NOLIST
1208 || listing_tail
->edict
== EDICT_NOLIST_NEXT
)
1209 listing_tail
->edict
= EDICT_NONE
;
1211 listing_tail
->edict
= EDICT_LIST
;
1214 listing_tail
->edict
= EDICT_NOLIST_NEXT
;
1223 listing_psize (width_only
)
1228 paper_height
= get_absolute_expression ();
1230 if (paper_height
< 0 || paper_height
> 1000)
1233 as_warn (_("strange paper height, set to no form"));
1236 if (*input_line_pointer
!= ',')
1238 demand_empty_rest_of_line ();
1242 ++input_line_pointer
;
1245 paper_width
= get_absolute_expression ();
1247 demand_empty_rest_of_line ();
1251 listing_nopage (ignore
)
1252 int ignore ATTRIBUTE_UNUSED
;
1258 listing_title (depth
)
1264 unsigned int length
;
1267 if (*input_line_pointer
!= '\"')
1272 ++input_line_pointer
;
1275 start
= input_line_pointer
;
1277 while (*input_line_pointer
)
1280 ? *input_line_pointer
== '\"'
1281 : is_end_of_line
[(unsigned char) *input_line_pointer
])
1285 length
= input_line_pointer
- start
;
1286 ttl
= xmalloc (length
+ 1);
1287 memcpy (ttl
, start
, length
);
1289 listing_tail
->edict
= depth
? EDICT_SBTTL
: EDICT_TITLE
;
1290 listing_tail
->edict_arg
= ttl
;
1293 input_line_pointer
++;
1294 demand_empty_rest_of_line ();
1297 else if (*input_line_pointer
== '\n')
1299 as_bad (_("new line in title"));
1300 demand_empty_rest_of_line ();
1305 input_line_pointer
++;
1311 listing_source_line (line
)
1317 listing_tail
->hll_line
= line
;
1323 listing_source_file (file
)
1327 listing_tail
->hll_file
= file_info (file
);
1332 /* Dummy functions for when compiled without listing enabled. */
1335 listing_flags (ignore
)
1349 listing_eject (ignore
)
1356 listing_psize (ignore
)
1363 listing_nopage (ignore
)
1370 listing_title (depth
)
1384 listing_newline (name
)
1391 listing_source_line (n
)
1398 listing_source_file (n
)