1 /* listing.c - maintain assembly listings
2 Copyright 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
3 2001, 2002, 2003, 2005, 2006, 2007
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 3, 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, 51 Franklin Street - Fifth Floor, Boston, MA
23 /* Contributed by Steve Chamberlain <sac@cygnus.com>
25 A listing page looks like:
27 LISTING_HEADER sourcefilename pagenumber
30 linenumber address data source
31 linenumber address data source
32 linenumber address data source
33 linenumber address data source
35 If not overridden, the listing commands are:
38 Put "stuff" onto the title line
40 Put stuff onto the subtitle line
42 If these commands come within 10 lines of the top of the page, they
43 will affect the page they are on, as well as any subsequent page
48 Increment the enable listing counter
50 Decrement the enable listing counter
53 Set the paper size to X wide and Y high. Setting a psize Y of
54 zero will suppress form feeds except where demanded by .eject
56 If the counter goes below zero, listing is suppressed.
58 Listings are a maintained by read calling various listing_<foo>
59 functions. What happens most is that the macro NO_LISTING is not
60 defined (from the Makefile), then the macro LISTING_NEWLINE expands
61 into a call to listing_newline. The call is done from read.c, every
62 time it sees a newline, and -l is on the command line.
64 The function listing_newline remembers the frag associated with the
65 newline, and creates a new frag - note that this is wasteful, but not
66 a big deal, since listing slows things down a lot anyway. The
67 function also remembers when the filename changes.
69 When all the input has finished, and gas has had a chance to settle
70 down, the listing is output. This is done by running down the list of
71 frag/source file records, and opening the files as needed and printing
72 out the bytes and chars associated with them.
74 The only things which the architecture can change about the listing
75 are defined in these macros:
77 LISTING_HEADER The name of the architecture
78 LISTING_WORD_SIZE The make of the number of bytes in a word, this determines
79 the clumping of the output data. eg a value of
80 2 makes words look like 1234 5678, whilst 1
81 would make the same value look like 12 34 56
83 LISTING_LHS_WIDTH Number of words of above size for the lhs
85 LISTING_LHS_WIDTH_SECOND Number of words for the data on the lhs
88 LISTING_LHS_CONT_LINES Max number of lines to use up for a continuation
89 LISTING_RHS_WIDTH Number of chars from the input file to print
94 #include "safe-ctype.h"
95 #include "input-file.h"
100 #ifndef LISTING_HEADER
101 #define LISTING_HEADER "GAS LISTING"
103 #ifndef LISTING_WORD_SIZE
104 #define LISTING_WORD_SIZE 4
106 #ifndef LISTING_LHS_WIDTH
107 #define LISTING_LHS_WIDTH ((LISTING_WORD_SIZE) > 4 ? 1 : 4 / (LISTING_WORD_SIZE))
109 #ifndef LISTING_LHS_WIDTH_SECOND
110 #define LISTING_LHS_WIDTH_SECOND LISTING_LHS_WIDTH
112 #ifndef LISTING_RHS_WIDTH
113 #define LISTING_RHS_WIDTH 100
115 #ifndef LISTING_LHS_CONT_LINES
116 #define LISTING_LHS_CONT_LINES 4
119 /* This structure remembers which .s were used. */
120 typedef struct file_info_struct
122 struct file_info_struct
* next
;
125 unsigned int linenum
;
129 /* This structure remembers which line from which file goes into which
131 struct list_info_struct
133 /* Frag which this line of source is nearest to. */
136 /* 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
;
153 /* High level language source line. */
154 unsigned int hll_line
;
156 /* Pointer to any error message associated with this line. */
171 /* Nonzero if this line is to be omitted because it contains
172 debugging information. This can become a flags field if we come
173 up with more information to store here. */
177 typedef struct list_info_struct list_info_type
;
179 int listing_lhs_width
= LISTING_LHS_WIDTH
;
180 int listing_lhs_width_second
= LISTING_LHS_WIDTH_SECOND
;
181 int listing_lhs_cont_lines
= LISTING_LHS_CONT_LINES
;
182 int listing_rhs_width
= LISTING_RHS_WIDTH
;
184 struct list_info_struct
* listing_tail
;
186 static file_info_type
* file_info_head
;
187 static file_info_type
* last_open_file_info
;
188 static FILE * last_open_file
;
189 static struct list_info_struct
* head
;
190 static int paper_width
= 200;
191 static int paper_height
= 60;
195 /* File to output listings to. */
196 static FILE *list_file
;
198 /* This static array is used to keep the text of data to be printed
199 before the start of the line. */
202 (((LISTING_WORD_SIZE * 2) + 1) * listing_lhs_width \
203 + ((((LISTING_WORD_SIZE * 2) + 1) * listing_lhs_width_second) \
204 * listing_lhs_cont_lines) \
207 static char *data_buffer
;
210 static void listing_message (const char *, const char *);
211 static file_info_type
*file_info (const char *);
212 static void new_frag (void);
213 static char *buffer_line (file_info_type
*, char *, unsigned int);
214 static void listing_page (list_info_type
*);
215 static unsigned int calc_hex (list_info_type
*);
216 static void print_lines (list_info_type
*, unsigned int, char *, unsigned int);
217 static void list_symbol_table (void);
218 static void print_source (file_info_type
*, list_info_type
*, char *, unsigned int);
219 static int debugging_pseudo (list_info_type
*, const char *);
220 static void listing_listing (char *);
223 listing_message (const char *name
, const char *message
)
225 if (listing_tail
!= (list_info_type
*) NULL
)
227 unsigned int l
= strlen (name
) + strlen (message
) + 1;
228 char *n
= (char *) xmalloc (l
);
231 listing_tail
->message
= n
;
236 listing_warning (const char *message
)
238 listing_message (_("Warning:"), message
);
242 listing_error (const char *message
)
244 listing_message (_("Error:"), message
);
247 static file_info_type
*
248 file_info (const char *file_name
)
250 /* Find an entry with this file name. */
251 file_info_type
*p
= file_info_head
;
253 while (p
!= (file_info_type
*) NULL
)
255 if (strcmp (p
->filename
, file_name
) == 0)
260 /* Make new entry. */
261 p
= xmalloc (sizeof (file_info_type
));
262 p
->next
= file_info_head
;
264 p
->filename
= xstrdup (file_name
);
275 frag_wane (frag_now
);
280 listing_newline (char *ps
)
284 static unsigned int last_line
= 0xffff;
285 static char *last_file
= NULL
;
286 list_info_type
*new = NULL
;
291 if (now_seg
== absolute_section
)
295 /* In ELF, anything in a section beginning with .debug or .line is
296 considered to be debugging information. This includes the
297 statement which switches us into the debugging section, which we
298 can only set after we are already in the debugging section. */
299 if ((listing
& LISTING_NODEBUG
) != 0
300 && listing_tail
!= NULL
301 && ! listing_tail
->debugging
)
305 segname
= segment_name (now_seg
);
306 if (strncmp (segname
, ".debug", sizeof ".debug" - 1) == 0
307 || strncmp (segname
, ".line", sizeof ".line" - 1) == 0)
308 listing_tail
->debugging
= 1;
312 as_where (&file
, &line
);
315 if (line
== last_line
316 && !(last_file
&& file
&& strcmp (file
, last_file
)))
319 new = (list_info_type
*) xmalloc (sizeof (list_info_type
));
321 /* Detect if we are reading from stdin by examining the file
322 name returned by as_where().
324 [FIXME: We rely upon the name in the strcmp below being the
325 same as the one used by input_scrub_new_file(), if that is
326 not true, then this code will fail].
328 If we are reading from stdin, then we need to save each input
329 line here (assuming of course that we actually have a line of
330 input to read), so that it can be displayed in the listing
331 that is produced at the end of the assembly. */
332 if (strcmp (file
, _("{standard input}")) == 0
333 && input_line_pointer
!= NULL
)
339 for (copy
= input_line_pointer
- 1;
341 || (! is_end_of_line
[(unsigned char) *copy
]));
343 if (*copy
== '"' && copy
[-1] != '\\')
344 seen_quote
= ! seen_quote
;
346 len
= (copy
- input_line_pointer
) + 2;
348 copy
= xmalloc (len
);
352 char *src
= input_line_pointer
- 1;
357 unsigned char c
= *src
++;
359 /* Omit control characters in the listing. */
367 new->line_contents
= copy
;
370 new->line_contents
= NULL
;
374 new = xmalloc (sizeof (list_info_type
));
375 new->line_contents
= ps
;
384 listing_tail
->next
= new;
390 new->frag
= frag_now
;
392 new->file
= file_info (file
);
393 new->next
= (list_info_type
*) NULL
;
394 new->message
= (char *) NULL
;
395 new->edict
= EDICT_NONE
;
396 new->hll_file
= (file_info_type
*) NULL
;
403 /* In ELF, anything in a section beginning with .debug or .line is
404 considered to be debugging information. */
405 if ((listing
& LISTING_NODEBUG
) != 0)
409 segname
= segment_name (now_seg
);
410 if (strncmp (segname
, ".debug", sizeof ".debug" - 1) == 0
411 || strncmp (segname
, ".line", sizeof ".line" - 1) == 0)
417 /* Attach all current frags to the previous line instead of the
418 current line. This is called by the MIPS backend when it discovers
419 that it needs to add some NOP instructions; the added NOP
420 instructions should go with the instruction that has the delay, not
421 with the new instruction. */
424 listing_prev_line (void)
429 if (head
== (list_info_type
*) NULL
430 || head
== listing_tail
)
435 for (l
= head
; l
->next
!= listing_tail
; l
= l
->next
)
438 for (f
= frchain_now
->frch_root
; f
!= (fragS
*) NULL
; f
= f
->fr_next
)
439 if (f
->line
== listing_tail
)
442 listing_tail
->frag
= frag_now
;
446 /* This function returns the next source line from the file supplied,
447 truncated to size. It appends a fake line to the end of each input
451 buffer_line (file_info_type
*file
, char *line
, unsigned int size
)
453 unsigned int count
= 0;
458 /* If we couldn't open the file, return an empty line. */
462 /* Check the cache and see if we last used this file. */
463 if (!last_open_file_info
|| file
!= last_open_file_info
)
467 last_open_file_info
->pos
= ftell (last_open_file
);
468 fclose (last_open_file
);
471 last_open_file_info
= file
;
472 last_open_file
= fopen (file
->filename
, FOPEN_RT
);
473 if (last_open_file
== NULL
)
479 /* Seek to where we were last time this file was open. */
481 fseek (last_open_file
, file
->pos
, SEEK_SET
);
484 c
= fgetc (last_open_file
);
486 /* Leave room for null. */
489 while (c
!= EOF
&& c
!= '\n')
495 c
= fgetc (last_open_file
);
501 if (count
+ 2 < size
)
513 static const char *fn
;
515 static unsigned int eject
; /* Eject pending */
516 static unsigned int page
; /* Current page number */
517 static char *title
; /* Current title */
518 static char *subtitle
; /* Current subtitle */
519 static unsigned int on_page
; /* Number of lines printed on current page */
522 listing_page (list_info_type
*list
)
524 /* Grope around, see if we can see a title or subtitle edict coming up
525 soon. (we look down 10 lines of the page and see if it's there) */
526 if ((eject
|| (on_page
>= (unsigned int) paper_height
))
527 && paper_height
!= 0)
531 int had_subtitle
= 0;
535 while (c
!= 0 && list
)
537 if (list
->edict
== EDICT_SBTTL
&& !had_subtitle
)
540 subtitle
= list
->edict_arg
;
542 if (list
->edict
== EDICT_TITLE
&& !had_title
)
545 title
= list
->edict_arg
;
553 fprintf (list_file
, "\f");
556 fprintf (list_file
, "%s %s \t\t\tpage %d\n", LISTING_HEADER
, fn
, page
);
557 fprintf (list_file
, "%s\n", title
);
558 fprintf (list_file
, "%s\n", subtitle
);
565 calc_hex (list_info_type
*list
)
567 int data_buffer_size
;
568 list_info_type
*first
= list
;
569 unsigned int address
= ~(unsigned int) 0;
572 unsigned int octet_in_frag
;
574 /* Find first frag which says it belongs to this line. */
576 while (frag
&& frag
->line
!= list
)
577 frag
= frag
->fr_next
;
581 data_buffer_size
= 0;
583 /* Dump all the frags which belong to this line. */
584 while (frag_ptr
!= (fragS
*) NULL
&& frag_ptr
->line
== first
)
586 /* Print as many bytes from the fixed part as is sensible. */
588 while ((offsetT
) octet_in_frag
< frag_ptr
->fr_fix
589 && data_buffer_size
< MAX_BYTES
- 3)
591 if (address
== ~(unsigned int) 0)
592 address
= frag_ptr
->fr_address
/ OCTETS_PER_BYTE
;
594 sprintf (data_buffer
+ data_buffer_size
,
596 (frag_ptr
->fr_literal
[octet_in_frag
]) & 0xff);
597 data_buffer_size
+= 2;
600 if (frag_ptr
->fr_type
== rs_fill
)
602 unsigned int var_rep_max
= octet_in_frag
;
603 unsigned int var_rep_idx
= octet_in_frag
;
605 /* Print as many bytes from the variable part as is sensible. */
606 while (((offsetT
) octet_in_frag
607 < (frag_ptr
->fr_fix
+ frag_ptr
->fr_var
* frag_ptr
->fr_offset
))
608 && data_buffer_size
< MAX_BYTES
- 3)
610 if (address
== ~(unsigned int) 0)
611 address
= frag_ptr
->fr_address
/ OCTETS_PER_BYTE
;
613 sprintf (data_buffer
+ data_buffer_size
,
615 (frag_ptr
->fr_literal
[var_rep_idx
]) & 0xff);
616 data_buffer_size
+= 2;
621 if ((offsetT
) var_rep_idx
>= frag_ptr
->fr_fix
+ frag_ptr
->fr_var
)
622 var_rep_idx
= var_rep_max
;
626 frag_ptr
= frag_ptr
->fr_next
;
628 data_buffer
[data_buffer_size
] = '\0';
633 print_lines (list_info_type
*list
, unsigned int lineno
,
634 char *string
, unsigned int address
)
639 unsigned int octet_in_word
= 0;
640 char *src
= data_buffer
;
643 /* Print the stuff on the first line. */
645 nchars
= (LISTING_WORD_SIZE
* 2 + 1) * listing_lhs_width
;
647 /* Print the hex for the first line. */
648 if (address
== ~(unsigned int) 0)
650 fprintf (list_file
, "% 4d ", lineno
);
651 for (idx
= 0; idx
< nchars
; idx
++)
652 fprintf (list_file
, " ");
654 fprintf (list_file
, "\t%s\n", string
? string
: "");
664 fprintf (list_file
, "% 4d ???? ", lineno
);
666 fprintf (list_file
, "% 4d %04x ", lineno
, address
);
668 /* And the data to go along with it. */
671 while (src
[cur
] && idx
< nchars
)
675 fprintf (list_file
, "%c%c", src
[offset
], src
[offset
+ 1]);
679 if (octet_in_word
== LISTING_WORD_SIZE
)
681 fprintf (list_file
, " ");
689 for (; idx
< nchars
; idx
++)
690 fprintf (list_file
, " ");
692 fprintf (list_file
, "\t%s\n", string
? string
: "");
698 fprintf (list_file
, "**** %s\n", list
->message
);
704 lines
< (unsigned int) listing_lhs_cont_lines
708 nchars
= ((LISTING_WORD_SIZE
* 2) + 1) * listing_lhs_width_second
- 1;
711 /* Print any more lines of data, but more compactly. */
712 fprintf (list_file
, "% 4d ", lineno
);
714 while (src
[cur
] && idx
< nchars
)
718 fprintf (list_file
, "%c%c", src
[offset
], src
[offset
+ 1]);
723 if (octet_in_word
== LISTING_WORD_SIZE
)
725 fprintf (list_file
, " ");
731 fprintf (list_file
, "\n");
738 list_symbol_table (void)
740 extern symbolS
*symbol_rootP
;
747 for (ptr
= symbol_rootP
; ptr
!= (symbolS
*) NULL
; ptr
= symbol_next (ptr
))
749 if (SEG_NORMAL (S_GET_SEGMENT (ptr
))
750 || S_GET_SEGMENT (ptr
) == absolute_section
)
752 /* Don't report section symbols. They are not interesting. */
753 if (symbol_section_p (ptr
))
756 if (S_GET_NAME (ptr
))
758 char buf
[30], fmt
[8];
759 valueT val
= S_GET_VALUE (ptr
);
761 /* @@ Note that this is dependent on the compilation options,
762 not solely on the target characteristics. */
763 if (sizeof (val
) == 4 && sizeof (int) == 4)
764 sprintf (buf
, "%08lx", (unsigned long) val
);
765 else if (sizeof (val
) <= sizeof (unsigned long))
767 sprintf (fmt
, "%%0%lulx",
768 (unsigned long) (sizeof (val
) * 2));
769 sprintf (buf
, fmt
, (unsigned long) val
);
772 else if (sizeof (val
) > 4)
773 sprintf_vma (buf
, val
);
780 fprintf (list_file
, "DEFINED SYMBOLS\n");
785 if (symbol_get_frag (ptr
) && symbol_get_frag (ptr
)->line
)
787 fprintf (list_file
, "%20s:%-5d %s:%s %s\n",
788 symbol_get_frag (ptr
)->line
->file
->filename
,
789 symbol_get_frag (ptr
)->line
->line
,
790 segment_name (S_GET_SEGMENT (ptr
)),
791 buf
, S_GET_NAME (ptr
));
795 fprintf (list_file
, "%33s:%s %s\n",
796 segment_name (S_GET_SEGMENT (ptr
)),
797 buf
, S_GET_NAME (ptr
));
808 fprintf (list_file
, "NO DEFINED SYMBOLS\n");
811 fprintf (list_file
, "\n");
817 for (ptr
= symbol_rootP
; ptr
!= (symbolS
*) NULL
; ptr
= symbol_next (ptr
))
819 if (S_GET_NAME (ptr
) && strlen (S_GET_NAME (ptr
)) != 0)
821 if (S_GET_SEGMENT (ptr
) == undefined_section
)
826 fprintf (list_file
, "UNDEFINED SYMBOLS\n");
830 fprintf (list_file
, "%s\n", S_GET_NAME (ptr
));
838 fprintf (list_file
, "NO UNDEFINED SYMBOLS\n");
845 print_source (file_info_type
*current_file
, list_info_type
*list
,
846 char *buffer
, unsigned int width
)
848 if (!current_file
->at_end
)
850 while (current_file
->linenum
< list
->hll_line
851 && !current_file
->at_end
)
853 char *p
= buffer_line (current_file
, buffer
, width
);
855 fprintf (list_file
, "%4u:%-13s **** %s\n", current_file
->linenum
,
856 current_file
->filename
, p
);
863 /* Sometimes the user doesn't want to be bothered by the debugging
864 records inserted by the compiler, see if the line is suspicious. */
867 debugging_pseudo (list_info_type
*list
, const char *line
)
878 was_debug
= in_debug
;
881 while (ISSPACE (*line
))
887 /* The ELF compiler sometimes emits blank lines after switching
888 out of a debugging section. If the next line drops us back
889 into debugging information, then don't print the blank line.
890 This is a hack for a particular compiler behaviour, not a
894 && list
->next
!= NULL
895 && list
->next
->debugging
)
907 if (strncmp (line
, "def", 3) == 0)
909 if (strncmp (line
, "val", 3) == 0)
911 if (strncmp (line
, "scl", 3) == 0)
913 if (strncmp (line
, "line", 4) == 0)
915 if (strncmp (line
, "endef", 5) == 0)
917 if (strncmp (line
, "ln", 2) == 0)
919 if (strncmp (line
, "type", 4) == 0)
921 if (strncmp (line
, "size", 4) == 0)
923 if (strncmp (line
, "dim", 3) == 0)
925 if (strncmp (line
, "tag", 3) == 0)
927 if (strncmp (line
, "stabs", 5) == 0)
929 if (strncmp (line
, "stabn", 5) == 0)
936 listing_listing (char *name ATTRIBUTE_UNUSED
)
938 list_info_type
*list
= head
;
939 file_info_type
*current_hll_file
= (file_info_type
*) NULL
;
943 int show_listing
= 1;
946 buffer
= xmalloc (listing_rhs_width
);
947 data_buffer
= xmalloc (MAX_BYTES
);
953 unsigned int list_line
;
955 width
= listing_rhs_width
> paper_width
? paper_width
:
958 list_line
= list
->line
;
962 /* Skip all lines up to the current. */
968 case EDICT_NOLIST_NEXT
:
969 if (show_listing
== 0)
977 title
= list
->edict_arg
;
980 subtitle
= list
->edict_arg
;
986 if (show_listing
<= 0)
988 while (list
->file
->linenum
< list_line
989 && !list
->file
->at_end
)
990 p
= buffer_line (list
->file
, buffer
, width
);
993 if (list
->edict
== EDICT_LIST
994 || (list
->edict
== EDICT_NOLIST_NEXT
&& show_listing
== 0))
996 /* Enable listing for the single line that caused the enable. */
1001 if (show_listing
> 0)
1003 /* Scan down the list and print all the stuff which can be done
1004 with this line (or lines). */
1008 current_hll_file
= list
->hll_file
;
1010 if (current_hll_file
&& list
->hll_line
&& (listing
& LISTING_HLL
))
1011 print_source (current_hll_file
, list
, buffer
, width
);
1013 if (list
->line_contents
)
1015 if (!((listing
& LISTING_NODEBUG
)
1016 && debugging_pseudo (list
, list
->line_contents
)))
1018 list
->file
->linenum
== 0 ? list
->line
: list
->file
->linenum
,
1019 list
->line_contents
, calc_hex (list
));
1021 free (list
->line_contents
);
1022 list
->line_contents
= NULL
;
1026 while (list
->file
->linenum
< list_line
1027 && !list
->file
->at_end
)
1029 unsigned int address
;
1031 p
= buffer_line (list
->file
, buffer
, width
);
1033 if (list
->file
->linenum
< list_line
)
1034 address
= ~(unsigned int) 0;
1036 address
= calc_hex (list
);
1038 if (!((listing
& LISTING_NODEBUG
)
1039 && debugging_pseudo (list
, p
)))
1040 print_lines (list
, list
->file
->linenum
, p
, address
);
1044 if (list
->edict
== EDICT_EJECT
)
1048 if (list
->edict
== EDICT_NOLIST_NEXT
&& show_listing
== 1)
1060 listing_print (char *name
)
1074 list_file
= fopen (name
, FOPEN_WT
);
1075 if (list_file
!= NULL
)
1079 as_warn (_("can't open %s: %s"), name
, xstrerror (errno
));
1085 if (listing
& LISTING_NOFORM
)
1088 if (listing
& LISTING_LISTING
)
1089 listing_listing (name
);
1091 if (listing
& LISTING_SYMBOLS
)
1092 list_symbol_table ();
1096 if (fclose (list_file
) == EOF
)
1097 as_warn (_("can't close %s: %s"), name
, xstrerror (errno
));
1101 fclose (last_open_file
);
1105 listing_file (const char *name
)
1111 listing_eject (int ignore ATTRIBUTE_UNUSED
)
1114 listing_tail
->edict
= EDICT_EJECT
;
1118 listing_flags (int ignore ATTRIBUTE_UNUSED
)
1120 while ((*input_line_pointer
++) && (*input_line_pointer
!= '\n'))
1121 input_line_pointer
++;
1125 /* Turn listing on or off. An argument of 0 means to turn off
1126 listing. An argument of 1 means to turn on listing. An argument
1127 of 2 means to turn off listing, but as of the next line; that is,
1128 the current line should be listed, but the next line should not. */
1131 listing_list (int on
)
1138 if (listing_tail
->edict
== EDICT_LIST
)
1139 listing_tail
->edict
= EDICT_NONE
;
1141 listing_tail
->edict
= EDICT_NOLIST
;
1144 if (listing_tail
->edict
== EDICT_NOLIST
1145 || listing_tail
->edict
== EDICT_NOLIST_NEXT
)
1146 listing_tail
->edict
= EDICT_NONE
;
1148 listing_tail
->edict
= EDICT_LIST
;
1151 listing_tail
->edict
= EDICT_NOLIST_NEXT
;
1160 listing_psize (int width_only
)
1164 paper_height
= get_absolute_expression ();
1166 if (paper_height
< 0 || paper_height
> 1000)
1169 as_warn (_("strange paper height, set to no form"));
1172 if (*input_line_pointer
!= ',')
1174 demand_empty_rest_of_line ();
1178 ++input_line_pointer
;
1181 paper_width
= get_absolute_expression ();
1183 demand_empty_rest_of_line ();
1187 listing_nopage (int ignore ATTRIBUTE_UNUSED
)
1193 listing_title (int depth
)
1198 unsigned int length
;
1201 if (*input_line_pointer
!= '\"')
1206 ++input_line_pointer
;
1209 start
= input_line_pointer
;
1211 while (*input_line_pointer
)
1214 ? *input_line_pointer
== '\"'
1215 : is_end_of_line
[(unsigned char) *input_line_pointer
])
1219 length
= input_line_pointer
- start
;
1220 ttl
= xmalloc (length
+ 1);
1221 memcpy (ttl
, start
, length
);
1223 listing_tail
->edict
= depth
? EDICT_SBTTL
: EDICT_TITLE
;
1224 listing_tail
->edict_arg
= ttl
;
1227 input_line_pointer
++;
1228 demand_empty_rest_of_line ();
1231 else if (*input_line_pointer
== '\n')
1233 as_bad (_("new line in title"));
1234 demand_empty_rest_of_line ();
1239 input_line_pointer
++;
1245 listing_source_line (unsigned int line
)
1250 listing_tail
->hll_line
= line
;
1256 listing_source_file (const char *file
)
1259 listing_tail
->hll_file
= file_info (file
);
1264 /* Dummy functions for when compiled without listing enabled. */
1267 listing_flags (int ignore
)
1273 listing_list (int on
)
1279 listing_eject (int ignore
)
1285 listing_psize (int ignore
)
1291 listing_nopage (int ignore
)
1297 listing_title (int depth
)
1303 listing_file (const char *name
)
1308 listing_newline (char *name
)
1313 listing_source_line (unsigned int n
)
1318 listing_source_file (const char *n
)