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
98 #include "input-file.h"
103 #ifndef LISTING_HEADER
104 #define LISTING_HEADER "GAS LISTING"
106 #ifndef LISTING_WORD_SIZE
107 #define LISTING_WORD_SIZE 4
109 #ifndef LISTING_LHS_WIDTH
110 #define LISTING_LHS_WIDTH ((LISTING_WORD_SIZE) > 4 ? 1 : 4 / (LISTING_WORD_SIZE))
112 #ifndef LISTING_LHS_WIDTH_SECOND
113 #define LISTING_LHS_WIDTH_SECOND LISTING_LHS_WIDTH
115 #ifndef LISTING_RHS_WIDTH
116 #define LISTING_RHS_WIDTH 100
118 #ifndef LISTING_LHS_CONT_LINES
119 #define LISTING_LHS_CONT_LINES 4
122 /* This structure remembers which .s were used. */
123 typedef struct file_info_struct
{
124 struct file_info_struct
* next
;
127 unsigned int linenum
;
131 /* This structure rememebrs which line from which file goes into which
133 struct list_info_struct
{
134 /* Frag which this line of source is nearest to. */
137 /* The actual line in the source file. */
139 /* Pointer to the file info struct for the file which this line
141 file_info_type
*file
;
143 /* The expanded text of any macro that may have been executing. */
147 struct list_info_struct
*next
;
149 /* Pointer to the file info struct for the high level language
150 source line that belongs here. */
151 file_info_type
*hll_file
;
152 /* High level language source line. */
153 unsigned int hll_line
;
155 /* Pointer to any error message associated with this line. */
169 /* Nonzero if this line is to be omitted because it contains
170 debugging information. This can become a flags field if we come
171 up with more information to store here. */
175 typedef struct list_info_struct list_info_type
;
177 int listing_lhs_width
= LISTING_LHS_WIDTH
;
178 int listing_lhs_width_second
= LISTING_LHS_WIDTH_SECOND
;
179 int listing_lhs_cont_lines
= LISTING_LHS_CONT_LINES
;
180 int listing_rhs_width
= LISTING_RHS_WIDTH
;
182 struct list_info_struct
* listing_tail
;
184 static file_info_type
* file_info_head
;
185 static file_info_type
* last_open_file_info
;
186 static FILE * last_open_file
;
187 static struct list_info_struct
* head
;
188 static int paper_width
= 200;
189 static int paper_height
= 60;
193 /* File to output listings to. */
194 static FILE *list_file
;
196 /* This static array is used to keep the text of data to be printed
197 before the start of the line. */
200 (((LISTING_WORD_SIZE * 2) + 1) * listing_lhs_width \
201 + ((((LISTING_WORD_SIZE * 2) + 1) * listing_lhs_width_second) \
202 * listing_lhs_cont_lines) \
205 static char *data_buffer
;
208 static void listing_message
PARAMS ((const char *name
, const char *message
));
209 static file_info_type
*file_info
PARAMS ((const char *file_name
));
210 static void new_frag
PARAMS ((void));
211 static char *buffer_line
PARAMS ((file_info_type
*file
,
212 char *line
, unsigned int size
));
213 static void listing_page
PARAMS ((list_info_type
*list
));
214 static unsigned int calc_hex
PARAMS ((list_info_type
*list
));
215 static void print_lines
PARAMS ((list_info_type
*, unsigned int,
216 char *, unsigned int));
217 static void list_symbol_table
PARAMS ((void));
218 static void print_source
PARAMS ((file_info_type
*current_file
,
219 list_info_type
*list
,
221 unsigned int width
));
222 static int debugging_pseudo
PARAMS ((list_info_type
*, const char *));
223 static void listing_listing
PARAMS ((char *name
));
226 listing_message (name
, message
)
230 if (listing_tail
!= (list_info_type
*) NULL
)
232 unsigned int l
= strlen (name
) + strlen (message
) + 1;
233 char *n
= (char *) xmalloc (l
);
236 listing_tail
->message
= n
;
241 listing_warning (message
)
244 listing_message (_("Warning:"), message
);
248 listing_error (message
)
251 listing_message (_("Error:"), message
);
254 static file_info_type
*
255 file_info (file_name
)
256 const char *file_name
;
258 /* Find an entry with this file name. */
259 file_info_type
*p
= file_info_head
;
261 while (p
!= (file_info_type
*) NULL
)
263 if (strcmp (p
->filename
, file_name
) == 0)
268 /* Make new entry. */
270 p
= (file_info_type
*) xmalloc (sizeof (file_info_type
));
271 p
->next
= file_info_head
;
273 p
->filename
= xmalloc ((unsigned long) strlen (file_name
) + 1);
274 strcpy (p
->filename
, file_name
);
286 frag_wane (frag_now
);
297 static unsigned int last_line
= 0xffff;
298 static char *last_file
= NULL
;
299 list_info_type
*new = NULL
;
304 if (now_seg
== absolute_section
)
308 /* In ELF, anything in a section beginning with .debug or .line is
309 considered to be debugging information. This includes the
310 statement which switches us into the debugging section, which we
311 can only set after we are already in the debugging section. */
312 if ((listing
& LISTING_NODEBUG
) != 0
313 && listing_tail
!= NULL
314 && ! listing_tail
->debugging
)
318 segname
= segment_name (now_seg
);
319 if (strncmp (segname
, ".debug", sizeof ".debug" - 1) == 0
320 || strncmp (segname
, ".line", sizeof ".line" - 1) == 0)
321 listing_tail
->debugging
= 1;
325 as_where (&file
, &line
);
328 if (line
== last_line
329 && !(last_file
&& file
&& strcmp (file
, last_file
)))
332 new = (list_info_type
*) xmalloc (sizeof (list_info_type
));
334 /* Detect if we are reading from stdin by examining the file
335 name returned by as_where().
337 [FIXME: We rely upon the name in the strcmp below being the
338 same as the one used by input_scrub_new_file(), if that is
339 not true, then this code will fail].
341 If we are reading from stdin, then we need to save each input
342 line here (assuming of course that we actually have a line of
343 input to read), so that it can be displayed in the listing
344 that is produced at the end of the assembly. */
345 if (strcmp (file
, _("{standard input}")) == 0
346 && input_line_pointer
!= NULL
)
352 for (copy
= input_line_pointer
- 1;
354 || (! is_end_of_line
[(unsigned char) *copy
]));
356 if (*copy
== '"' && copy
[-1] != '\\')
357 seen_quote
= ! seen_quote
;
359 len
= (copy
- input_line_pointer
) + 2;
361 copy
= xmalloc (len
);
365 char *src
= input_line_pointer
- 1;
370 unsigned char c
= *src
++;
372 /* Omit control characters in the listing. */
373 if (isascii (c
) && ! iscntrl (c
))
380 new->line_contents
= copy
;
383 new->line_contents
= NULL
;
387 new = (list_info_type
*) xmalloc (sizeof (list_info_type
));
388 new->line_contents
= ps
;
397 listing_tail
->next
= new;
403 new->frag
= frag_now
;
405 new->file
= file_info (file
);
406 new->next
= (list_info_type
*) NULL
;
407 new->message
= (char *) NULL
;
408 new->edict
= EDICT_NONE
;
409 new->hll_file
= (file_info_type
*) NULL
;
416 /* In ELF, anything in a section beginning with .debug or .line is
417 considered to be debugging information. */
418 if ((listing
& LISTING_NODEBUG
) != 0)
422 segname
= segment_name (now_seg
);
423 if (strncmp (segname
, ".debug", sizeof ".debug" - 1) == 0
424 || strncmp (segname
, ".line", sizeof ".line" - 1) == 0)
430 /* Attach all current frags to the previous line instead of the
431 current line. This is called by the MIPS backend when it discovers
432 that it needs to add some NOP instructions; the added NOP
433 instructions should go with the instruction that has the delay, not
434 with the new instruction. */
442 if (head
== (list_info_type
*) NULL
443 || head
== listing_tail
)
448 for (l
= head
; l
->next
!= listing_tail
; l
= l
->next
)
451 for (f
= frchain_now
->frch_root
; f
!= (fragS
*) NULL
; f
= f
->fr_next
)
452 if (f
->line
== listing_tail
)
455 listing_tail
->frag
= frag_now
;
459 /* This function returns the next source line from the file supplied,
460 truncated to size. It appends a fake line to the end of each input
464 buffer_line (file
, line
, size
)
465 file_info_type
*file
;
469 unsigned int count
= 0;
474 /* If we couldn't open the file, return an empty line. */
478 /* Check the cache and see if we last used this file. */
479 if (!last_open_file_info
|| file
!= last_open_file_info
)
483 last_open_file_info
->pos
= ftell (last_open_file
);
484 fclose (last_open_file
);
487 last_open_file_info
= file
;
488 last_open_file
= fopen (file
->filename
, "r");
489 if (last_open_file
== NULL
)
495 /* Seek to where we were last time this file was open. */
497 fseek (last_open_file
, file
->pos
, SEEK_SET
);
500 c
= fgetc (last_open_file
);
502 /* Leave room for null. */
505 while (c
!= EOF
&& c
!= '\n')
511 c
= fgetc (last_open_file
);
526 static const char *fn
;
528 static unsigned int eject
; /* Eject pending */
529 static unsigned int page
; /* Current page number */
530 static char *title
; /* Current title */
531 static char *subtitle
; /* Current subtitle */
532 static unsigned int on_page
; /* Number of lines printed on current page */
536 list_info_type
*list
;
538 /* Grope around, see if we can see a title or subtitle edict coming up
539 soon. (we look down 10 lines of the page and see if it's there) */
540 if ((eject
|| (on_page
>= (unsigned int) paper_height
))
541 && paper_height
!= 0)
545 int had_subtitle
= 0;
549 while (c
!= 0 && list
)
551 if (list
->edict
== EDICT_SBTTL
&& !had_subtitle
)
554 subtitle
= list
->edict_arg
;
556 if (list
->edict
== EDICT_TITLE
&& !had_title
)
559 title
= list
->edict_arg
;
567 fprintf (list_file
, "\f");
570 fprintf (list_file
, "%s %s \t\t\tpage %d\n", LISTING_HEADER
, fn
, page
);
571 fprintf (list_file
, "%s\n", title
);
572 fprintf (list_file
, "%s\n", subtitle
);
580 list_info_type
*list
;
582 int data_buffer_size
;
583 list_info_type
*first
= list
;
584 unsigned int address
= ~(unsigned int) 0;
587 unsigned int octet_in_frag
;
589 /* Find first frag which says it belongs to this line. */
591 while (frag
&& frag
->line
!= list
)
592 frag
= frag
->fr_next
;
596 data_buffer_size
= 0;
598 /* Dump all the frags which belong to this line. */
599 while (frag_ptr
!= (fragS
*) NULL
&& frag_ptr
->line
== first
)
601 /* Print as many bytes from the fixed part as is sensible. */
603 while ((offsetT
) octet_in_frag
< frag_ptr
->fr_fix
604 && data_buffer_size
< MAX_BYTES
- 3)
606 if (address
== ~(unsigned int) 0)
608 address
= frag_ptr
->fr_address
/ OCTETS_PER_BYTE
;
611 sprintf (data_buffer
+ data_buffer_size
,
613 (frag_ptr
->fr_literal
[octet_in_frag
]) & 0xff);
614 data_buffer_size
+= 2;
617 if (frag_ptr
->fr_type
== rs_fill
)
619 unsigned int var_rep_max
= octet_in_frag
;
620 unsigned int var_rep_idx
= octet_in_frag
;
622 /* Print as many bytes from the variable part as is sensible. */
623 while (((offsetT
) octet_in_frag
624 < (frag_ptr
->fr_fix
+ frag_ptr
->fr_var
* frag_ptr
->fr_offset
))
625 && data_buffer_size
< MAX_BYTES
- 3)
627 if (address
== ~(unsigned int) 0)
629 address
= frag_ptr
->fr_address
/ OCTETS_PER_BYTE
;
631 sprintf (data_buffer
+ data_buffer_size
,
633 (frag_ptr
->fr_literal
[var_rep_idx
]) & 0xff);
635 data_buffer
[data_buffer_size
++] = '*';
636 data_buffer
[data_buffer_size
++] = '*';
638 data_buffer_size
+= 2;
643 if ((offsetT
) var_rep_idx
>= frag_ptr
->fr_fix
+ frag_ptr
->fr_var
)
644 var_rep_idx
= var_rep_max
;
648 frag_ptr
= frag_ptr
->fr_next
;
650 data_buffer
[data_buffer_size
] = '\0';
655 print_lines (list
, lineno
, string
, address
)
656 list_info_type
*list
;
659 unsigned int address
;
664 unsigned int octet_in_word
= 0;
665 char *src
= data_buffer
;
668 /* Print the stuff on the first line. */
670 nchars
= (LISTING_WORD_SIZE
* 2 + 1) * listing_lhs_width
;
672 /* Print the hex for the first line. */
673 if (address
== ~(unsigned int) 0)
675 fprintf (list_file
, "% 4d ", lineno
);
676 for (idx
= 0; idx
< nchars
; idx
++)
677 fprintf (list_file
, " ");
679 fprintf (list_file
, "\t%s\n", string
? string
: "");
689 fprintf (list_file
, "% 4d ???? ", lineno
);
691 fprintf (list_file
, "% 4d %04x ", lineno
, address
);
693 /* And the data to go along with it. */
696 while (src
[cur
] && idx
< nchars
)
700 fprintf (list_file
, "%c%c", src
[offset
], src
[offset
+ 1]);
704 if (octet_in_word
== LISTING_WORD_SIZE
)
706 fprintf (list_file
, " ");
714 for (; idx
< nchars
; idx
++)
715 fprintf (list_file
, " ");
717 fprintf (list_file
, "\t%s\n", string
? string
: "");
723 fprintf (list_file
, "**** %s\n", list
->message
);
729 lines
< (unsigned int) listing_lhs_cont_lines
733 nchars
= ((LISTING_WORD_SIZE
* 2) + 1) * listing_lhs_width_second
- 1;
736 /* Print any more lines of data, but more compactly. */
737 fprintf (list_file
, "% 4d ", lineno
);
739 while (src
[cur
] && idx
< nchars
)
743 fprintf (list_file
, "%c%c", src
[offset
], src
[offset
+ 1]);
748 if (octet_in_word
== LISTING_WORD_SIZE
)
750 fprintf (list_file
, " ");
756 fprintf (list_file
, "\n");
765 extern symbolS
*symbol_rootP
;
772 for (ptr
= symbol_rootP
; ptr
!= (symbolS
*) NULL
; ptr
= symbol_next (ptr
))
774 if (SEG_NORMAL (S_GET_SEGMENT (ptr
))
775 || S_GET_SEGMENT (ptr
) == absolute_section
)
778 /* Don't report section symbols. They are not interesting. */
779 if (symbol_section_p (ptr
))
782 if (S_GET_NAME (ptr
))
784 char buf
[30], fmt
[8];
785 valueT val
= S_GET_VALUE (ptr
);
787 /* @@ Note that this is dependent on the compilation options,
788 not solely on the target characteristics. */
789 if (sizeof (val
) == 4 && sizeof (int) == 4)
790 sprintf (buf
, "%08lx", (unsigned long) val
);
791 else if (sizeof (val
) <= sizeof (unsigned long))
793 sprintf (fmt
, "%%0%lulx",
794 (unsigned long) (sizeof (val
) * 2));
795 sprintf (buf
, fmt
, (unsigned long) val
);
798 else if (sizeof (val
) > 4)
799 sprintf_vma (buf
, val
);
806 fprintf (list_file
, "DEFINED SYMBOLS\n");
811 if (symbol_get_frag (ptr
) && symbol_get_frag (ptr
)->line
)
813 fprintf (list_file
, "%20s:%-5d %s:%s %s\n",
814 symbol_get_frag (ptr
)->line
->file
->filename
,
815 symbol_get_frag (ptr
)->line
->line
,
816 segment_name (S_GET_SEGMENT (ptr
)),
817 buf
, S_GET_NAME (ptr
));
821 fprintf (list_file
, "%33s:%s %s\n",
822 segment_name (S_GET_SEGMENT (ptr
)),
823 buf
, S_GET_NAME (ptr
));
834 fprintf (list_file
, "NO DEFINED SYMBOLS\n");
837 fprintf (list_file
, "\n");
843 for (ptr
= symbol_rootP
; ptr
!= (symbolS
*) NULL
; ptr
= symbol_next (ptr
))
845 if (S_GET_NAME (ptr
) && strlen (S_GET_NAME (ptr
)) != 0)
847 if (S_GET_SEGMENT (ptr
) == undefined_section
)
852 fprintf (list_file
, "UNDEFINED SYMBOLS\n");
856 fprintf (list_file
, "%s\n", S_GET_NAME (ptr
));
864 fprintf (list_file
, "NO UNDEFINED SYMBOLS\n");
871 print_source (current_file
, list
, buffer
, width
)
872 file_info_type
*current_file
;
873 list_info_type
*list
;
877 if (!current_file
->at_end
)
879 while (current_file
->linenum
< list
->hll_line
880 && !current_file
->at_end
)
882 char *p
= buffer_line (current_file
, buffer
, width
);
883 fprintf (list_file
, "%4u:%-13s **** %s\n", current_file
->linenum
,
884 current_file
->filename
, p
);
891 /* Sometimes the user doesn't want to be bothered by the debugging
892 records inserted by the compiler, see if the line is suspicious. */
895 debugging_pseudo (list
, line
)
896 list_info_type
*list
;
908 was_debug
= in_debug
;
911 while (isspace ((unsigned char) *line
))
917 /* The ELF compiler sometimes emits blank lines after switching
918 out of a debugging section. If the next line drops us back
919 into debugging information, then don't print the blank line.
920 This is a hack for a particular compiler behaviour, not a
924 && list
->next
!= NULL
925 && list
->next
->debugging
)
937 if (strncmp (line
, "def", 3) == 0)
939 if (strncmp (line
, "val", 3) == 0)
941 if (strncmp (line
, "scl", 3) == 0)
943 if (strncmp (line
, "line", 4) == 0)
945 if (strncmp (line
, "endef", 5) == 0)
947 if (strncmp (line
, "ln", 2) == 0)
949 if (strncmp (line
, "type", 4) == 0)
951 if (strncmp (line
, "size", 4) == 0)
953 if (strncmp (line
, "dim", 3) == 0)
955 if (strncmp (line
, "tag", 3) == 0)
958 if (strncmp (line
, "stabs", 5) == 0)
960 if (strncmp (line
, "stabn", 5) == 0)
967 listing_listing (name
)
968 char *name ATTRIBUTE_UNUSED
;
970 list_info_type
*list
= head
;
971 file_info_type
*current_hll_file
= (file_info_type
*) NULL
;
975 int show_listing
= 1;
978 buffer
= xmalloc (listing_rhs_width
);
979 data_buffer
= xmalloc (MAX_BYTES
);
983 while (list
!= (list_info_type
*) NULL
&& 0)
986 list
->frag
= list
->next
->frag
;
995 unsigned int list_line
;
997 width
= listing_rhs_width
> paper_width
? paper_width
:
1000 list_line
= list
->line
;
1001 switch (list
->edict
)
1004 /* Skip all lines up to the current. */
1010 case EDICT_NOLIST_NEXT
:
1011 if (show_listing
== 0)
1019 title
= list
->edict_arg
;
1022 subtitle
= list
->edict_arg
;
1028 if (show_listing
<= 0)
1030 while (list
->file
->linenum
< list_line
1031 && !list
->file
->at_end
)
1032 p
= buffer_line (list
->file
, buffer
, width
);
1035 if (list
->edict
== EDICT_LIST
1036 || (list
->edict
== EDICT_NOLIST_NEXT
&& show_listing
== 0))
1038 /* Enable listing for the single line that caused the enable. */
1043 if (show_listing
> 0)
1045 /* Scan down the list and print all the stuff which can be done
1046 with this line (or lines). */
1051 current_hll_file
= list
->hll_file
;
1054 if (current_hll_file
&& list
->hll_line
&& (listing
& LISTING_HLL
))
1056 print_source (current_hll_file
, list
, buffer
, width
);
1059 if (list
->line_contents
)
1061 if (!((listing
& LISTING_NODEBUG
)
1062 && debugging_pseudo (list
, list
->line_contents
)))
1065 list
->file
->linenum
== 0 ? list
->line
: list
->file
->linenum
,
1066 list
->line_contents
, calc_hex (list
));
1068 free (list
->line_contents
);
1069 list
->line_contents
= NULL
;
1073 while (list
->file
->linenum
< list_line
1074 && !list
->file
->at_end
)
1076 unsigned int address
;
1078 p
= buffer_line (list
->file
, buffer
, width
);
1080 if (list
->file
->linenum
< list_line
)
1081 address
= ~(unsigned int) 0;
1083 address
= calc_hex (list
);
1085 if (!((listing
& LISTING_NODEBUG
)
1086 && debugging_pseudo (list
, p
)))
1087 print_lines (list
, list
->file
->linenum
, p
, address
);
1091 if (list
->edict
== EDICT_EJECT
)
1097 if (list
->edict
== EDICT_NOLIST_NEXT
&& show_listing
== 1)
1109 listing_print (name
)
1124 list_file
= fopen (name
, "w");
1125 if (list_file
!= NULL
)
1129 as_perror (_("can't open list file: %s"), name
);
1135 if (listing
& LISTING_NOFORM
)
1140 if (listing
& LISTING_LISTING
)
1142 listing_listing (name
);
1145 if (listing
& LISTING_SYMBOLS
)
1147 list_symbol_table ();
1152 if (fclose (list_file
) == EOF
)
1153 as_perror (_("error closing list file: %s"), name
);
1158 fclose (last_open_file
);
1170 listing_eject (ignore
)
1171 int ignore ATTRIBUTE_UNUSED
;
1174 listing_tail
->edict
= EDICT_EJECT
;
1178 listing_flags (ignore
)
1179 int ignore ATTRIBUTE_UNUSED
;
1181 while ((*input_line_pointer
++) && (*input_line_pointer
!= '\n'))
1182 input_line_pointer
++;
1186 /* Turn listing on or off. An argument of 0 means to turn off
1187 listing. An argument of 1 means to turn on listing. An argument
1188 of 2 means to turn off listing, but as of the next line; that is,
1189 the current line should be listed, but the next line should not. */
1200 if (listing_tail
->edict
== EDICT_LIST
)
1201 listing_tail
->edict
= EDICT_NONE
;
1203 listing_tail
->edict
= EDICT_NOLIST
;
1206 if (listing_tail
->edict
== EDICT_NOLIST
1207 || listing_tail
->edict
== EDICT_NOLIST_NEXT
)
1208 listing_tail
->edict
= EDICT_NONE
;
1210 listing_tail
->edict
= EDICT_LIST
;
1213 listing_tail
->edict
= EDICT_NOLIST_NEXT
;
1222 listing_psize (width_only
)
1227 paper_height
= get_absolute_expression ();
1229 if (paper_height
< 0 || paper_height
> 1000)
1232 as_warn (_("strange paper height, set to no form"));
1235 if (*input_line_pointer
!= ',')
1237 demand_empty_rest_of_line ();
1241 ++input_line_pointer
;
1244 paper_width
= get_absolute_expression ();
1246 demand_empty_rest_of_line ();
1250 listing_nopage (ignore
)
1251 int ignore ATTRIBUTE_UNUSED
;
1257 listing_title (depth
)
1263 unsigned int length
;
1266 if (*input_line_pointer
!= '\"')
1271 ++input_line_pointer
;
1274 start
= input_line_pointer
;
1276 while (*input_line_pointer
)
1279 ? *input_line_pointer
== '\"'
1280 : is_end_of_line
[(unsigned char) *input_line_pointer
])
1284 length
= input_line_pointer
- start
;
1285 ttl
= xmalloc (length
+ 1);
1286 memcpy (ttl
, start
, length
);
1288 listing_tail
->edict
= depth
? EDICT_SBTTL
: EDICT_TITLE
;
1289 listing_tail
->edict_arg
= ttl
;
1292 input_line_pointer
++;
1293 demand_empty_rest_of_line ();
1296 else if (*input_line_pointer
== '\n')
1298 as_bad (_("New line in title"));
1299 demand_empty_rest_of_line ();
1304 input_line_pointer
++;
1310 listing_source_line (line
)
1316 listing_tail
->hll_line
= line
;
1322 listing_source_file (file
)
1326 listing_tail
->hll_file
= file_info (file
);
1331 /* Dummy functions for when compiled without listing enabled. */
1334 listing_flags (ignore
)
1348 listing_eject (ignore
)
1355 listing_psize (ignore
)
1362 listing_nopage (ignore
)
1369 listing_title (depth
)
1383 listing_newline (name
)
1390 listing_source_line (n
)
1397 listing_source_file (n
)