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
= xmalloc ((unsigned long) strlen (file_name
) + 1);
273 strcpy (p
->filename
, file_name
);
285 frag_wane (frag_now
);
296 static unsigned int last_line
= 0xffff;
297 static char *last_file
= NULL
;
298 list_info_type
*new = NULL
;
303 if (now_seg
== absolute_section
)
307 /* In ELF, anything in a section beginning with .debug or .line is
308 considered to be debugging information. This includes the
309 statement which switches us into the debugging section, which we
310 can only set after we are already in the debugging section. */
311 if ((listing
& LISTING_NODEBUG
) != 0
312 && listing_tail
!= NULL
313 && ! listing_tail
->debugging
)
317 segname
= segment_name (now_seg
);
318 if (strncmp (segname
, ".debug", sizeof ".debug" - 1) == 0
319 || strncmp (segname
, ".line", sizeof ".line" - 1) == 0)
320 listing_tail
->debugging
= 1;
324 as_where (&file
, &line
);
327 if (line
== last_line
328 && !(last_file
&& file
&& strcmp (file
, last_file
)))
331 new = (list_info_type
*) xmalloc (sizeof (list_info_type
));
333 /* Detect if we are reading from stdin by examining the file
334 name returned by as_where().
336 [FIXME: We rely upon the name in the strcmp below being the
337 same as the one used by input_scrub_new_file(), if that is
338 not true, then this code will fail].
340 If we are reading from stdin, then we need to save each input
341 line here (assuming of course that we actually have a line of
342 input to read), so that it can be displayed in the listing
343 that is produced at the end of the assembly. */
344 if (strcmp (file
, _("{standard input}")) == 0
345 && input_line_pointer
!= NULL
)
351 for (copy
= input_line_pointer
- 1;
353 || (! is_end_of_line
[(unsigned char) *copy
]));
355 if (*copy
== '"' && copy
[-1] != '\\')
356 seen_quote
= ! seen_quote
;
358 len
= (copy
- input_line_pointer
) + 2;
360 copy
= xmalloc (len
);
364 char *src
= input_line_pointer
- 1;
369 unsigned char c
= *src
++;
371 /* Omit control characters in the listing. */
379 new->line_contents
= copy
;
382 new->line_contents
= NULL
;
386 new = (list_info_type
*) xmalloc (sizeof (list_info_type
));
387 new->line_contents
= ps
;
396 listing_tail
->next
= new;
402 new->frag
= frag_now
;
404 new->file
= file_info (file
);
405 new->next
= (list_info_type
*) NULL
;
406 new->message
= (char *) NULL
;
407 new->edict
= EDICT_NONE
;
408 new->hll_file
= (file_info_type
*) NULL
;
415 /* In ELF, anything in a section beginning with .debug or .line is
416 considered to be debugging information. */
417 if ((listing
& LISTING_NODEBUG
) != 0)
421 segname
= segment_name (now_seg
);
422 if (strncmp (segname
, ".debug", sizeof ".debug" - 1) == 0
423 || strncmp (segname
, ".line", sizeof ".line" - 1) == 0)
429 /* Attach all current frags to the previous line instead of the
430 current line. This is called by the MIPS backend when it discovers
431 that it needs to add some NOP instructions; the added NOP
432 instructions should go with the instruction that has the delay, not
433 with the new instruction. */
441 if (head
== (list_info_type
*) NULL
442 || head
== listing_tail
)
447 for (l
= head
; l
->next
!= listing_tail
; l
= l
->next
)
450 for (f
= frchain_now
->frch_root
; f
!= (fragS
*) NULL
; f
= f
->fr_next
)
451 if (f
->line
== listing_tail
)
454 listing_tail
->frag
= frag_now
;
458 /* This function returns the next source line from the file supplied,
459 truncated to size. It appends a fake line to the end of each input
463 buffer_line (file
, line
, size
)
464 file_info_type
*file
;
468 unsigned int count
= 0;
473 /* If we couldn't open the file, return an empty line. */
477 /* Check the cache and see if we last used this file. */
478 if (!last_open_file_info
|| file
!= last_open_file_info
)
482 last_open_file_info
->pos
= ftell (last_open_file
);
483 fclose (last_open_file
);
486 last_open_file_info
= file
;
487 last_open_file
= fopen (file
->filename
, FOPEN_RT
);
488 if (last_open_file
== NULL
)
494 /* Seek to where we were last time this file was open. */
496 fseek (last_open_file
, file
->pos
, SEEK_SET
);
499 c
= fgetc (last_open_file
);
501 /* Leave room for null. */
504 while (c
!= EOF
&& c
!= '\n')
510 c
= fgetc (last_open_file
);
516 if (count
+ 2 < size
)
528 static const char *fn
;
530 static unsigned int eject
; /* Eject pending */
531 static unsigned int page
; /* Current page number */
532 static char *title
; /* Current title */
533 static char *subtitle
; /* Current subtitle */
534 static unsigned int on_page
; /* Number of lines printed on current page */
538 list_info_type
*list
;
540 /* Grope around, see if we can see a title or subtitle edict coming up
541 soon. (we look down 10 lines of the page and see if it's there) */
542 if ((eject
|| (on_page
>= (unsigned int) paper_height
))
543 && paper_height
!= 0)
547 int had_subtitle
= 0;
551 while (c
!= 0 && list
)
553 if (list
->edict
== EDICT_SBTTL
&& !had_subtitle
)
556 subtitle
= list
->edict_arg
;
558 if (list
->edict
== EDICT_TITLE
&& !had_title
)
561 title
= list
->edict_arg
;
569 fprintf (list_file
, "\f");
572 fprintf (list_file
, "%s %s \t\t\tpage %d\n", LISTING_HEADER
, fn
, page
);
573 fprintf (list_file
, "%s\n", title
);
574 fprintf (list_file
, "%s\n", subtitle
);
582 list_info_type
*list
;
584 int data_buffer_size
;
585 list_info_type
*first
= list
;
586 unsigned int address
= ~(unsigned int) 0;
589 unsigned int octet_in_frag
;
591 /* Find first frag which says it belongs to this line. */
593 while (frag
&& frag
->line
!= list
)
594 frag
= frag
->fr_next
;
598 data_buffer_size
= 0;
600 /* Dump all the frags which belong to this line. */
601 while (frag_ptr
!= (fragS
*) NULL
&& frag_ptr
->line
== first
)
603 /* Print as many bytes from the fixed part as is sensible. */
605 while ((offsetT
) octet_in_frag
< frag_ptr
->fr_fix
606 && data_buffer_size
< MAX_BYTES
- 3)
608 if (address
== ~(unsigned int) 0)
610 address
= frag_ptr
->fr_address
/ OCTETS_PER_BYTE
;
613 sprintf (data_buffer
+ data_buffer_size
,
615 (frag_ptr
->fr_literal
[octet_in_frag
]) & 0xff);
616 data_buffer_size
+= 2;
619 if (frag_ptr
->fr_type
== rs_fill
)
621 unsigned int var_rep_max
= octet_in_frag
;
622 unsigned int var_rep_idx
= octet_in_frag
;
624 /* Print as many bytes from the variable part as is sensible. */
625 while (((offsetT
) octet_in_frag
626 < (frag_ptr
->fr_fix
+ frag_ptr
->fr_var
* frag_ptr
->fr_offset
))
627 && data_buffer_size
< MAX_BYTES
- 3)
629 if (address
== ~(unsigned int) 0)
631 address
= frag_ptr
->fr_address
/ OCTETS_PER_BYTE
;
633 sprintf (data_buffer
+ data_buffer_size
,
635 (frag_ptr
->fr_literal
[var_rep_idx
]) & 0xff);
637 data_buffer
[data_buffer_size
++] = '*';
638 data_buffer
[data_buffer_size
++] = '*';
640 data_buffer_size
+= 2;
645 if ((offsetT
) var_rep_idx
>= frag_ptr
->fr_fix
+ frag_ptr
->fr_var
)
646 var_rep_idx
= var_rep_max
;
650 frag_ptr
= frag_ptr
->fr_next
;
652 data_buffer
[data_buffer_size
] = '\0';
657 print_lines (list
, lineno
, string
, address
)
658 list_info_type
*list
;
661 unsigned int address
;
666 unsigned int octet_in_word
= 0;
667 char *src
= data_buffer
;
670 /* Print the stuff on the first line. */
672 nchars
= (LISTING_WORD_SIZE
* 2 + 1) * listing_lhs_width
;
674 /* Print the hex for the first line. */
675 if (address
== ~(unsigned int) 0)
677 fprintf (list_file
, "% 4d ", lineno
);
678 for (idx
= 0; idx
< nchars
; idx
++)
679 fprintf (list_file
, " ");
681 fprintf (list_file
, "\t%s\n", string
? string
: "");
691 fprintf (list_file
, "% 4d ???? ", lineno
);
693 fprintf (list_file
, "% 4d %04x ", lineno
, address
);
695 /* And the data to go along with it. */
698 while (src
[cur
] && idx
< nchars
)
702 fprintf (list_file
, "%c%c", src
[offset
], src
[offset
+ 1]);
706 if (octet_in_word
== LISTING_WORD_SIZE
)
708 fprintf (list_file
, " ");
716 for (; idx
< nchars
; idx
++)
717 fprintf (list_file
, " ");
719 fprintf (list_file
, "\t%s\n", string
? string
: "");
725 fprintf (list_file
, "**** %s\n", list
->message
);
731 lines
< (unsigned int) listing_lhs_cont_lines
735 nchars
= ((LISTING_WORD_SIZE
* 2) + 1) * listing_lhs_width_second
- 1;
738 /* Print any more lines of data, but more compactly. */
739 fprintf (list_file
, "% 4d ", lineno
);
741 while (src
[cur
] && idx
< nchars
)
745 fprintf (list_file
, "%c%c", src
[offset
], src
[offset
+ 1]);
750 if (octet_in_word
== LISTING_WORD_SIZE
)
752 fprintf (list_file
, " ");
758 fprintf (list_file
, "\n");
767 extern symbolS
*symbol_rootP
;
774 for (ptr
= symbol_rootP
; ptr
!= (symbolS
*) NULL
; ptr
= symbol_next (ptr
))
776 if (SEG_NORMAL (S_GET_SEGMENT (ptr
))
777 || S_GET_SEGMENT (ptr
) == absolute_section
)
780 /* Don't report section symbols. They are not interesting. */
781 if (symbol_section_p (ptr
))
784 if (S_GET_NAME (ptr
))
786 char buf
[30], fmt
[8];
787 valueT val
= S_GET_VALUE (ptr
);
789 /* @@ Note that this is dependent on the compilation options,
790 not solely on the target characteristics. */
791 if (sizeof (val
) == 4 && sizeof (int) == 4)
792 sprintf (buf
, "%08lx", (unsigned long) val
);
793 else if (sizeof (val
) <= sizeof (unsigned long))
795 sprintf (fmt
, "%%0%lulx",
796 (unsigned long) (sizeof (val
) * 2));
797 sprintf (buf
, fmt
, (unsigned long) val
);
800 else if (sizeof (val
) > 4)
801 sprintf_vma (buf
, val
);
808 fprintf (list_file
, "DEFINED SYMBOLS\n");
813 if (symbol_get_frag (ptr
) && symbol_get_frag (ptr
)->line
)
815 fprintf (list_file
, "%20s:%-5d %s:%s %s\n",
816 symbol_get_frag (ptr
)->line
->file
->filename
,
817 symbol_get_frag (ptr
)->line
->line
,
818 segment_name (S_GET_SEGMENT (ptr
)),
819 buf
, S_GET_NAME (ptr
));
823 fprintf (list_file
, "%33s:%s %s\n",
824 segment_name (S_GET_SEGMENT (ptr
)),
825 buf
, S_GET_NAME (ptr
));
836 fprintf (list_file
, "NO DEFINED SYMBOLS\n");
839 fprintf (list_file
, "\n");
845 for (ptr
= symbol_rootP
; ptr
!= (symbolS
*) NULL
; ptr
= symbol_next (ptr
))
847 if (S_GET_NAME (ptr
) && strlen (S_GET_NAME (ptr
)) != 0)
849 if (S_GET_SEGMENT (ptr
) == undefined_section
)
854 fprintf (list_file
, "UNDEFINED SYMBOLS\n");
858 fprintf (list_file
, "%s\n", S_GET_NAME (ptr
));
866 fprintf (list_file
, "NO UNDEFINED SYMBOLS\n");
873 print_source (current_file
, list
, buffer
, width
)
874 file_info_type
*current_file
;
875 list_info_type
*list
;
879 if (!current_file
->at_end
)
881 while (current_file
->linenum
< list
->hll_line
882 && !current_file
->at_end
)
884 char *p
= buffer_line (current_file
, buffer
, width
);
885 fprintf (list_file
, "%4u:%-13s **** %s\n", current_file
->linenum
,
886 current_file
->filename
, p
);
893 /* Sometimes the user doesn't want to be bothered by the debugging
894 records inserted by the compiler, see if the line is suspicious. */
897 debugging_pseudo (list
, line
)
898 list_info_type
*list
;
910 was_debug
= in_debug
;
913 while (ISSPACE (*line
))
919 /* The ELF compiler sometimes emits blank lines after switching
920 out of a debugging section. If the next line drops us back
921 into debugging information, then don't print the blank line.
922 This is a hack for a particular compiler behaviour, not a
926 && list
->next
!= NULL
927 && list
->next
->debugging
)
939 if (strncmp (line
, "def", 3) == 0)
941 if (strncmp (line
, "val", 3) == 0)
943 if (strncmp (line
, "scl", 3) == 0)
945 if (strncmp (line
, "line", 4) == 0)
947 if (strncmp (line
, "endef", 5) == 0)
949 if (strncmp (line
, "ln", 2) == 0)
951 if (strncmp (line
, "type", 4) == 0)
953 if (strncmp (line
, "size", 4) == 0)
955 if (strncmp (line
, "dim", 3) == 0)
957 if (strncmp (line
, "tag", 3) == 0)
960 if (strncmp (line
, "stabs", 5) == 0)
962 if (strncmp (line
, "stabn", 5) == 0)
969 listing_listing (name
)
970 char *name ATTRIBUTE_UNUSED
;
972 list_info_type
*list
= head
;
973 file_info_type
*current_hll_file
= (file_info_type
*) NULL
;
977 int show_listing
= 1;
980 buffer
= xmalloc (listing_rhs_width
);
981 data_buffer
= xmalloc (MAX_BYTES
);
985 while (list
!= (list_info_type
*) NULL
&& 0)
988 list
->frag
= list
->next
->frag
;
997 unsigned int list_line
;
999 width
= listing_rhs_width
> paper_width
? paper_width
:
1002 list_line
= list
->line
;
1003 switch (list
->edict
)
1006 /* Skip all lines up to the current. */
1012 case EDICT_NOLIST_NEXT
:
1013 if (show_listing
== 0)
1021 title
= list
->edict_arg
;
1024 subtitle
= list
->edict_arg
;
1030 if (show_listing
<= 0)
1032 while (list
->file
->linenum
< list_line
1033 && !list
->file
->at_end
)
1034 p
= buffer_line (list
->file
, buffer
, width
);
1037 if (list
->edict
== EDICT_LIST
1038 || (list
->edict
== EDICT_NOLIST_NEXT
&& show_listing
== 0))
1040 /* Enable listing for the single line that caused the enable. */
1045 if (show_listing
> 0)
1047 /* Scan down the list and print all the stuff which can be done
1048 with this line (or lines). */
1053 current_hll_file
= list
->hll_file
;
1056 if (current_hll_file
&& list
->hll_line
&& (listing
& LISTING_HLL
))
1058 print_source (current_hll_file
, list
, buffer
, width
);
1061 if (list
->line_contents
)
1063 if (!((listing
& LISTING_NODEBUG
)
1064 && debugging_pseudo (list
, list
->line_contents
)))
1067 list
->file
->linenum
== 0 ? list
->line
: list
->file
->linenum
,
1068 list
->line_contents
, calc_hex (list
));
1070 free (list
->line_contents
);
1071 list
->line_contents
= NULL
;
1075 while (list
->file
->linenum
< list_line
1076 && !list
->file
->at_end
)
1078 unsigned int address
;
1080 p
= buffer_line (list
->file
, buffer
, width
);
1082 if (list
->file
->linenum
< list_line
)
1083 address
= ~(unsigned int) 0;
1085 address
= calc_hex (list
);
1087 if (!((listing
& LISTING_NODEBUG
)
1088 && debugging_pseudo (list
, p
)))
1089 print_lines (list
, list
->file
->linenum
, p
, address
);
1093 if (list
->edict
== EDICT_EJECT
)
1099 if (list
->edict
== EDICT_NOLIST_NEXT
&& show_listing
== 1)
1111 listing_print (name
)
1126 list_file
= fopen (name
, FOPEN_WT
);
1127 if (list_file
!= NULL
)
1131 as_perror (_("can't open list file: %s"), name
);
1137 if (listing
& LISTING_NOFORM
)
1142 if (listing
& LISTING_LISTING
)
1144 listing_listing (name
);
1147 if (listing
& LISTING_SYMBOLS
)
1149 list_symbol_table ();
1154 if (fclose (list_file
) == EOF
)
1155 as_perror (_("error closing list file: %s"), name
);
1160 fclose (last_open_file
);
1172 listing_eject (ignore
)
1173 int ignore ATTRIBUTE_UNUSED
;
1176 listing_tail
->edict
= EDICT_EJECT
;
1180 listing_flags (ignore
)
1181 int ignore ATTRIBUTE_UNUSED
;
1183 while ((*input_line_pointer
++) && (*input_line_pointer
!= '\n'))
1184 input_line_pointer
++;
1188 /* Turn listing on or off. An argument of 0 means to turn off
1189 listing. An argument of 1 means to turn on listing. An argument
1190 of 2 means to turn off listing, but as of the next line; that is,
1191 the current line should be listed, but the next line should not. */
1202 if (listing_tail
->edict
== EDICT_LIST
)
1203 listing_tail
->edict
= EDICT_NONE
;
1205 listing_tail
->edict
= EDICT_NOLIST
;
1208 if (listing_tail
->edict
== EDICT_NOLIST
1209 || listing_tail
->edict
== EDICT_NOLIST_NEXT
)
1210 listing_tail
->edict
= EDICT_NONE
;
1212 listing_tail
->edict
= EDICT_LIST
;
1215 listing_tail
->edict
= EDICT_NOLIST_NEXT
;
1224 listing_psize (width_only
)
1229 paper_height
= get_absolute_expression ();
1231 if (paper_height
< 0 || paper_height
> 1000)
1234 as_warn (_("strange paper height, set to no form"));
1237 if (*input_line_pointer
!= ',')
1239 demand_empty_rest_of_line ();
1243 ++input_line_pointer
;
1246 paper_width
= get_absolute_expression ();
1248 demand_empty_rest_of_line ();
1252 listing_nopage (ignore
)
1253 int ignore ATTRIBUTE_UNUSED
;
1259 listing_title (depth
)
1265 unsigned int length
;
1268 if (*input_line_pointer
!= '\"')
1273 ++input_line_pointer
;
1276 start
= input_line_pointer
;
1278 while (*input_line_pointer
)
1281 ? *input_line_pointer
== '\"'
1282 : is_end_of_line
[(unsigned char) *input_line_pointer
])
1286 length
= input_line_pointer
- start
;
1287 ttl
= xmalloc (length
+ 1);
1288 memcpy (ttl
, start
, length
);
1290 listing_tail
->edict
= depth
? EDICT_SBTTL
: EDICT_TITLE
;
1291 listing_tail
->edict_arg
= ttl
;
1294 input_line_pointer
++;
1295 demand_empty_rest_of_line ();
1298 else if (*input_line_pointer
== '\n')
1300 as_bad (_("new line in title"));
1301 demand_empty_rest_of_line ();
1306 input_line_pointer
++;
1312 listing_source_line (line
)
1318 listing_tail
->hll_line
= line
;
1324 listing_source_file (file
)
1328 listing_tail
->hll_file
= file_info (file
);
1333 /* Dummy functions for when compiled without listing enabled. */
1336 listing_flags (ignore
)
1350 listing_eject (ignore
)
1357 listing_psize (ignore
)
1364 listing_nopage (ignore
)
1371 listing_title (depth
)
1385 listing_newline (name
)
1392 listing_source_line (n
)
1399 listing_source_file (n
)