fix libbfd.h declaration, by tweaking elf.c comment, so bfd can compile
[deliverable/binutils-gdb.git] / gas / listing.c
CommitLineData
5d9f0ecf
SC
1/* listing.c - mainting assembly listings
2 Copyright (C) 1991, 1992 Free Software Foundation, Inc.
c593cf41
SC
3
4This file is part of GAS, the GNU Assembler.
5
6GAS is free software; you can redistribute it and/or modify
7it under the terms of the GNU General Public License as published by
8the Free Software Foundation; either version 2, or (at your option)
9any later version.
10
11GAS is distributed in the hope that it will be useful,
12but WITHOUT ANY WARRANTY; without even the implied warranty of
13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14GNU General Public License for more details.
15
16You should have received a copy of the GNU General Public License
17along with GAS; see the file COPYING. If not, write to
18the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
5d9f0ecf
SC
19
20/*
c593cf41
SC
21 Contributed by Steve Chamberlain
22 sac@cygnus.com
23
24
25 A listing page looks like:
26
27 LISTING_HEADER sourcefilename pagenumber
28 TITLE LINE
29 SUBTITLE LINE
30 linenumber address data source
31 linenumber address data source
32 linenumber address data source
33 linenumber address data source
34
35 If not overridden, the listing commands are:
36
37 .title "stuff"
38 Put "stuff" onto the title line
39 .sbttl "stuff"
40 Put stuff onto the subtitle line
41
5d9f0ecf
SC
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
c593cf41
SC
44
45 .eject
46 Thow a page
47 .list
48 Increment the enable listing counter
49 .nolist
50 Decrement the enable listing counter
51
52 .psize Y[,X]
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
55
56 If the counter goes below zero, listing is suppressed.
57
58
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.
64
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.
69
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.
74
75 The only things which the architecture can change about the listing
76 are defined in these macros:
77
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
83 78
84 LISTING_LHS_WIDTH Number of words of above size for the lhs
85
86 LISTING_LHS_WIDTH_SECOND Number of words for the data on the lhs
87 for the second line
88
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
91 on a line
92*/
5d9f0ecf
SC
93
94#include "as.h"
95#include <obstack.h>
96#include "input-file.h"
97#include "targ-cpu.h"
98
7143f43c
SC
99char *malloc();
100
5d9f0ecf
SC
101#ifndef NO_LISTING
102#ifndef LISTING_HEADER
103#define LISTING_HEADER "GAS LISTING"
104#endif
105#ifndef LISTING_WORD_SIZE
106#define LISTING_WORD_SIZE 4
107#endif
108#ifndef LISTING_LHS_WIDTH
109#define LISTING_LHS_WIDTH 1
110#endif
111#ifndef LISTING_LHS_WIDTH_SECOND
112#define LISTING_LHS_WIDTH_SECOND 1
113#endif
114#ifndef LISTING_RHS_WIDTH
115#define LISTING_RHS_WIDTH 100
116#endif
117#ifndef LISTING_LHS_CONT_LINES
118#define LISTING_LHS_CONT_LINES 4
119#endif
120
121
c593cf41
SC
122
123
b3ca913f 124/* This structure remembers which .s were used */
c593cf41
SC
125typedef struct file_info_struct
126{
127 char *filename;
128 int linenum;
129 FILE *file;
130 struct file_info_struct *next;
131 int end_pending;
132
5d9f0ecf
SC
133} file_info_type ;
134
c593cf41
SC
135
136/* this structure rememebrs which line from which file goes into which
137 frag */
138typedef struct list_info_struct
139{
140 /* Frag which this line of source is nearest to */
141 fragS *frag;
142 /* The actual line in the source file */
143 unsigned int line;
144 /* Pointer to the file info struct for the file which this line
145 belongs to */
146 file_info_type *file;
147
148 /* Next in list */
149 struct list_info_struct *next;
a39116f1 150
c593cf41
SC
151
152 /* Pointer to the file info struct for the high level language
153 source line that belongs here */
154 file_info_type *hll_file;
155
156 /* High level language source line */
157 int hll_line;
158
159
160 /* Pointer to any error message associated with this line */
161 char *message;
162
163 enum
164 {
165 EDICT_NONE,
166 EDICT_SBTTL,
167 EDICT_TITLE,
168 EDICT_NOLIST,
169 EDICT_LIST,
170 EDICT_EJECT
171 } edict;
172 char *edict_arg;
173
5d9f0ecf
SC
174} list_info_type;
175
c593cf41 176
5d9f0ecf
SC
177static struct list_info_struct *head;
178struct list_info_struct *listing_tail;
179extern int listing;
180extern unsigned int physical_input_line;
181extern fragS *frag_now;
182
c593cf41 183
5d9f0ecf
SC
184static int paper_width = 200;
185static int paper_height = 60;
186
c593cf41 187
5d9f0ecf 188/* this static array is used to keep the text of data to be printed
c593cf41
SC
189 before the start of the line.
190 It is stored so we can give a bit more info on the next line. To much, and large
191 initialized arrays will use up lots of paper.
192 */
5d9f0ecf
SC
193
194static char data_buffer[100];
195static unsigned int data_buffer_size;
196
c593cf41 197
5d9f0ecf 198static void
c593cf41
SC
199DEFUN(listing_message,(name, message),
200 char *name AND
201 char *message)
202{
203 unsigned int l = strlen(name) + strlen(message)+1;
7143f43c 204 char *n = (char*)malloc(l);
c593cf41
SC
205 strcpy(n,name);
206 strcat(n,message);
207 if(listing_tail != (list_info_type *)NULL)
208 {
209 listing_tail->message = n;
210 }
211
212}
213
214
5d9f0ecf
SC
215
216
217void
c593cf41
SC
218DEFUN(listing_warning,(message),
219 char *message)
5d9f0ecf 220{
c593cf41 221 listing_message("Warning:", message);
5d9f0ecf
SC
222}
223
c593cf41
SC
224void
225DEFUN(listing_error,(message),
226 char *message)
5d9f0ecf 227{
c593cf41 228 listing_message("Error:", message);
5d9f0ecf
SC
229}
230
c593cf41
SC
231
232
233
5d9f0ecf
SC
234static file_info_type *file_info_head;
235
236static file_info_type *
c593cf41
SC
237DEFUN(file_info, (file_name),
238 char *file_name)
5d9f0ecf 239{
c593cf41
SC
240 /* Find an entry with this file name */
241 file_info_type *p = file_info_head;
242
243 while (p != (file_info_type *)NULL)
244 {
245 if (strcmp(p->filename, file_name) == 0)
246 return p;
247 p = p->next;
248 }
249
250 /* Make new entry */
251
252 p = (file_info_type *)xmalloc(sizeof(file_info_type));
253 p->next = file_info_head;
254 file_info_head = p;
255 p->filename = xmalloc(strlen(file_name)+1);
256 strcpy(p->filename, file_name);
257 p->linenum = 0;
258 p->end_pending = 0;
259
7143f43c
SC
260 p->file = fopen(p->filename,"rb");
261if (p->file) fgetc(p->file);
262
263
264
c593cf41
SC
265 return p;
266
267}
5d9f0ecf
SC
268
269
b3ca913f 270static void
c593cf41 271DEFUN_VOID(new_frag)
b3ca913f 272{
c593cf41
SC
273
274 frag_wane(frag_now);
275 frag_new(0);
276
b3ca913f
SC
277}
278
5d9f0ecf 279void
c593cf41
SC
280DEFUN(listing_newline,(ps),
281 char *ps)
5d9f0ecf 282{
c593cf41
SC
283 char *s = ps;
284 extern char *file_name;
285 static unsigned int last_line =0xffff ;
5d9f0ecf 286
c593cf41
SC
287
288 list_info_type *new;
289 if (physical_input_line != last_line)
290 {
291 last_line = physical_input_line;
292 new_frag();
293
294 new = (list_info_type *)malloc(sizeof(list_info_type));
295 new->frag = frag_now;
296 new->line = physical_input_line ;
297 new->file = file_info(file_name);
298
299 if (listing_tail)
300 {
301 listing_tail->next = new;
302 }
303 else
304 {
305 head = new;
306 }
307 listing_tail = new;
308 new->next = (list_info_type *)NULL;
309 new->message = (char *)NULL;
310 new->edict = EDICT_NONE;
311 new->hll_file = (file_info_type*)NULL;
312 new->hll_line = 0;
313 new_frag();
314 }
315}
5d9f0ecf 316
3340f7e5 317
c593cf41
SC
318/*
319 This function returns the next source line from the file supplied,
320 truncated to size. It appends a fake line to the end of each input
321 file to make
322*/
5d9f0ecf
SC
323
324static char *
c593cf41
SC
325DEFUN(buffer_line,(file, line, size),
326 file_info_type *file AND
327 char *line AND
328 unsigned int size)
5d9f0ecf 329{
c593cf41
SC
330 unsigned int count = 0;
331 int c;
332
333 char *p = line;
334
335 /* If we couldn't open the file, return an empty line */
336 if (file->file == (FILE*)NULL)
337 {
338 return "";
339 }
340
ab737e51
SC
341 if (file->linenum == 0)
342 rewind(file->file);
343
c593cf41
SC
344 if (file->end_pending == 10) {
345 *p ++ = '\n';
7143f43c 346 fseek(file->file, 0,0 );
c593cf41
SC
347 file->linenum = 0;
348 file->end_pending = 0;
349 }
350 c = fgetc(file->file);
7143f43c
SC
351
352
c593cf41
SC
353 size -= 1; /* leave room for null */
354
355 while (c != EOF && c != '\n')
356 {
357 if (count < size)
358 *p++ = c;
359 count++;
360
361 c= fgetc(file->file);
7143f43c 362
c593cf41
SC
363 }
364 if (c == EOF)
365 {
366 file->end_pending ++;
7143f43c
SC
367 *p++ = '.';
368 *p++ = '.';
369 *p++ = '.';
c593cf41
SC
370 }
371 file->linenum++;
372 *p++ = 0;
373 return line;
374}
375
5d9f0ecf
SC
376
377static char *fn;
378
379static unsigned int eject; /* Eject pending */
380static unsigned int page; /* Current page number */
381static char *title; /* current title */
382static char *subtitle; /* current subtitle */
383static unsigned int on_page; /* number of lines printed on current page */
384
3340f7e5 385
c593cf41
SC
386static void
387DEFUN(listing_page,(list),
388 list_info_type *list)
389{
390 /* Grope around, see if we can see a title or subtitle edict coming up
391 soon (we look down 10 lines of the page and see if it's there)*/
392 if ((eject || (on_page >= paper_height)) && paper_height != 0)
393 {
394 unsigned int c = 10;
395 int had_title = 0;
396 int had_subtitle = 0;
397
398 page++;
399
400 while (c != 0 && list)
401 {
402 if (list->edict == EDICT_SBTTL && !had_subtitle)
403 {
404 had_subtitle = 1;
405 subtitle = list->edict_arg;
406 }
407 if (list->edict == EDICT_TITLE && !had_title)
408 {
409 had_title = 1;
410 title = list->edict_arg;
411 }
412 list = list->next;
413 c--;
414 }
415
416
417 if (page > 1)
418 {
419 printf("\f");
420 }
421
422 printf("%s %s \t\t\tpage %d\n", LISTING_HEADER, fn, page);
423 printf("%s\n", title);
424 printf("%s\n", subtitle);
425 on_page = 3;
426 eject = 0;
427 }
428}
5d9f0ecf
SC
429
430
431static unsigned int
c593cf41
SC
432DEFUN(calc_hex,(list),
433 list_info_type *list)
5d9f0ecf 434{
c593cf41
SC
435 list_info_type *first = list;
436 list_info_type *last = first;
437 unsigned int address = ~0;
438
439 fragS *frag;
440 fragS *frag_ptr;
441
442 unsigned int byte_in_frag = 0;
443
444 int anything = 0;
445
446 /* Find first frag which says it belongs to this line */
447 frag = list->frag;
448 while (frag && frag->line != list)
449 frag = frag->fr_next;
450
451 frag_ptr = frag;
452
453 data_buffer_size = 0;
454
455 /* Dump all the frags which belong to this line */
456 while (frag_ptr != (fragS *)NULL && frag_ptr->line == first)
457 {
458 /* Print as many bytes from the fixed part as is sensible */
459 while(byte_in_frag < frag_ptr->fr_fix && data_buffer_size < sizeof(data_buffer)-10)
460 {
461 if (address == ~0)
462 {
463 address = frag_ptr->fr_address;
464 }
465
466 sprintf(data_buffer + data_buffer_size,
467 "%02X",
468 (frag_ptr->fr_literal[byte_in_frag]) & 0xff);
469 data_buffer_size += 2;
470 byte_in_frag++;
471 }
472 {
473 unsigned int var_rep_max = byte_in_frag;
474 unsigned int var_rep_idx = byte_in_frag;
475
476 /* Print as many bytes from the variable part as is sensible */
477 while (byte_in_frag < frag_ptr->fr_var * frag_ptr->fr_offset
478 && data_buffer_size < sizeof(data_buffer)-10)
479 {
480 if (address == ~0)
481 {
482 address = frag_ptr->fr_address;
483 }
484sprintf(data_buffer + data_buffer_size,
485 "%02X",
486 (frag_ptr->fr_literal[var_rep_idx]) & 0xff);
487#if 0
488 data_buffer[data_buffer_size++] = '*';
489 data_buffer[data_buffer_size++] = '*';
490#endif
491 data_buffer_size +=2;
492
493 var_rep_idx ++;
494 byte_in_frag++;
495
496 if (var_rep_idx >= frag_ptr->fr_var)
497 var_rep_idx = var_rep_max;
498 }
499 }
500
501 frag_ptr = frag_ptr->fr_next;
502 }
503 data_buffer[data_buffer_size++] = 0;
504 return address;
505}
506
507
508
509
510
5d9f0ecf
SC
511
512static void
c593cf41
SC
513DEFUN(print_lines,(list, string, address),
514list_info_type *list AND
515char *string AND
516unsigned int address)
517{
518 unsigned int idx;
519 unsigned int nchars;
520 unsigned int lines;
521 unsigned int byte_in_word =0;
522 char *src = data_buffer;
523
524 /* Print the stuff on the first line */
525 listing_page(list);
526 nchars = (LISTING_WORD_SIZE*2 +1) * LISTING_LHS_WIDTH ;
527 /* Print the hex for the first line */
528 if (address == ~0)
529 {
530 printf("% 4d ", list->line);
531 for (idx = 0; idx < nchars; idx++)
532 printf(" ");
533
534 printf("\t%s\n", string ? string : "");
535 on_page++;
536 listing_page(0);
537
538 }
539 else
540 {
541 if (had_errors())
542 {
543 printf("% 4d ???? ", list->line);
544 }
545 else
546 {
547 printf("% 4d %04x ", list->line, address);
548 }
549
550 /* And the data to go along with it */
551 idx = 0;
552
553 while (*src && idx < nchars)
554 {
555 printf("%c%c", src[0], src[1]);
556 src += 2;
557 byte_in_word++;
558 if (byte_in_word == LISTING_WORD_SIZE)
559 {
560 printf(" ");
561 idx++;
562 byte_in_word = 0;
563 }
564 idx+=2;
565 }
566
567 for (;idx < nchars; idx++)
568 printf(" ");
569
570 printf("\t%s\n", string ? string : "");
571 on_page++;
572 listing_page(list);
573 if (list->message)
574 {
575 printf("**** %s\n",list->message);
576 listing_page(list);
577 on_page++;
578 }
579
580 for (lines = 0;
581 lines < LISTING_LHS_CONT_LINES
582 && *src;
583 lines++) {
584 nchars = ((LISTING_WORD_SIZE*2) +1) * LISTING_LHS_WIDTH_SECOND -1;
585 idx = 0;
586 /* Print any more lines of data, but more compactly */
587 printf("% 4d ", list->line);
588
589 while (*src && idx < nchars)
590 {
591 printf("%c%c", src[0], src[1]);
592 src+=2;
593 idx+=2;
594 byte_in_word++;
595 if (byte_in_word == LISTING_WORD_SIZE)
596 {
597 printf(" ");
598 idx++;
599 byte_in_word = 0;
600 }
601 }
5d9f0ecf 602
c593cf41
SC
603 printf("\n");
604 on_page++;
5d9f0ecf 605 listing_page(list);
3340f7e5 606
c593cf41
SC
607 }
608
609
610 }
611}
612
613
614
615
5d9f0ecf
SC
616
617
618static void
c593cf41 619DEFUN_VOID(list_symbol_table)
5d9f0ecf 620{
c593cf41
SC
621 extern symbolS *symbol_rootP;
622
623 symbolS *ptr ;
624 eject = 1;
625 listing_page(0);
626 printf("DEFINED SYMBOLS\n");
627 on_page++;
628
629 for (ptr = symbol_rootP; ptr != (symbolS*)NULL; ptr = symbol_next(ptr))
630 {
631 if (ptr->sy_frag->line)
632 {
7143f43c
SC
633 if (S_GET_NAME(ptr))
634 {
635
c593cf41
SC
636 if (strlen(S_GET_NAME(ptr)))
637 {
638 printf("%20s:%-5d %2d:%08x %s \n",
639 ptr->sy_frag->line->file->filename,
640 ptr->sy_frag->line->line,
641 S_GET_SEGMENT(ptr),
642 S_GET_VALUE(ptr),
643 S_GET_NAME(ptr));
7143f43c
SC
644 }
645
646 else
647 {
648 printf("%20s:%-5d %2d:%08x\n",
649 ptr->sy_frag->line->file->filename,
650 ptr->sy_frag->line->line,
651 S_GET_SEGMENT(ptr),
652 S_GET_VALUE(ptr));
653
c593cf41 654
7143f43c
SC
655 }
656
3d38ac61
SC
657 on_page++;
658 listing_page(0);
c593cf41
SC
659 }
660 }
661
662 }
663 printf("\n");
664 on_page++;
665 listing_page(0);
666 printf("UNDEFINED SYMBOLS\n");
667 on_page++;
668 listing_page(0);
669
670 for (ptr = symbol_rootP; ptr != (symbolS*)NULL; ptr = symbol_next(ptr))
671 {
7143f43c 672 if (S_GET_NAME(ptr) && strlen(S_GET_NAME(ptr)) != 0)
c593cf41
SC
673 {
674 if (ptr->sy_frag->line == 0)
675 {
676 printf("%s\n", S_GET_NAME(ptr));
b3ca913f
SC
677 on_page++;
678 listing_page(0);
c593cf41
SC
679 }
680 }
681 }
682}
5d9f0ecf 683
b3ca913f 684void
c593cf41
SC
685DEFUN(print_source,(current_file, list, buffer, width),
686 file_info_type *current_file AND
687 list_info_type *list AND
688 char *buffer AND
689 unsigned int width)
690{
691 if (current_file->file) {
692 while (current_file->linenum < list->hll_line)
693 {
694 char * p = buffer_line(current_file, buffer, width);
695 printf("%4d:%-13s **** %s\n", current_file->linenum, current_file->filename, p);
696 on_page++;
697 listing_page(list);
698 }
699 }
700}
b3ca913f 701
a39116f1
RP
702/* Sometimes the user doesn't want to be bothered by the debugging
703 records inserted by the compiler, see if the line is suspicioous */
5d9f0ecf 704
a39116f1 705static int
c593cf41
SC
706DEFUN(debugging_pseudo,(line),
707 char *line)
a39116f1 708{
c593cf41
SC
709 while (isspace(*line))
710 line++;
711
712 if(*line != '.') return 0;
713
714 line++;
715
716 if (strncmp(line, "def",3) == 0) return 1;
717 if (strncmp(line, "val",3) == 0) return 1;
718 if (strncmp(line, "scl",3) == 0) return 1;
719 if (strncmp(line, "line",4) == 0) return 1;
720 if (strncmp(line, "endef",5) == 0) return 1;
721 if (strncmp(line, "ln",2) ==0) return 1;
722 if (strncmp(line, "type",4) ==0) return 1;
723 if (strncmp(line, "size",4) == 0) return 1;
724 if (strncmp(line, "dim",3) ==0) return 1;
725 if (strncmp(line, "tag",3) == 0) return 1;
726
727 return 0;
728
729}
5d9f0ecf 730
a39116f1 731void
c593cf41
SC
732DEFUN(listing_listing,(name),
733 char *name)
734{
735 list_info_type *list = head;
736 file_info_type *current_hll_file = (file_info_type *)NULL;
737
738 unsigned int page= 1;
739 unsigned int prev = 0;
740 char *message;
741 char *buffer;
742 char *p;
743 unsigned int addr = 0;
744 int on_page = 0;
745 int show_listing = 1;
746 unsigned int width;
747
748 buffer = malloc(LISTING_RHS_WIDTH);
749 eject = 1;
750 list = head;
751
752 while (list != (list_info_type *)NULL && 0)
753 {
754 if (list->next)
755 list->frag = list->next->frag;
756 list = list->next;
757
758 }
759
760 list = head->next;
761
762
763 while ( list)
764 {
765 width = LISTING_RHS_WIDTH > paper_width ? paper_width :
766 LISTING_RHS_WIDTH;
767
768 switch (list->edict) {
769 case EDICT_LIST:
770 show_listing++;
771 break;
772 case EDICT_NOLIST:
773 show_listing--;
774 break;
775 case EDICT_EJECT:
776 break;
777 case EDICT_NONE:
778 break;
779 case EDICT_TITLE:
780 title = list->edict_arg;
781 break;
782 case EDICT_SBTTL:
783 subtitle = list->edict_arg;
784 break;
785 default:
786 abort();
787 }
788
789 if (show_listing > 0)
790 {
791 /* Scan down the list and print all the stuff which can be done
792 with this line (or lines) */
793 message = 0;
794
795 if (list->hll_file)
796 {
797 current_hll_file = list->hll_file;
798 }
799
800 if (current_hll_file && list->hll_line && listing & LISTING_HLL)
801 {
802 print_source(current_hll_file, list, buffer, width);
803 }
804
805 p = buffer_line(list->file, buffer, width);
806
807 if (! ((listing & LISTING_NODEBUG) && debugging_pseudo(p)))
808 {
809 print_lines(list, p, calc_hex(list));
810 }
811
812 if (list->edict == EDICT_EJECT)
813 {
5d9f0ecf 814 eject = 1;
c593cf41
SC
815 }
816 }
817 else
818 {
819
820 p = buffer_line(list->file, buffer, width);
821 }
822
823 list = list->next;
824 }
825 free(buffer);
826}
5d9f0ecf
SC
827
828void
c593cf41
SC
829DEFUN(listing_print,(name),
830 char *name)
5d9f0ecf 831{
c593cf41
SC
832 title = "";
833 subtitle = "";
834
835 if (listing & LISTING_NOFORM)
836 {
837 paper_height = 0;
838 }
839
840 if (listing & LISTING_LISTING)
841 {
842 listing_listing(name);
843
844 }
845 if (listing & LISTING_SYMBOLS)
846 {
847 list_symbol_table();
848 }
849}
5d9f0ecf
SC
850
851
852void
c593cf41
SC
853DEFUN(listing_file,(name),
854char *name)
5d9f0ecf 855{
c593cf41 856 fn = name;
5d9f0ecf
SC
857}
858
859void
c593cf41 860DEFUN_VOID(listing_eject)
5d9f0ecf 861{
c593cf41 862 listing_tail->edict = EDICT_EJECT;
5d9f0ecf
SC
863}
864
865void
c593cf41 866DEFUN_VOID(listing_flags)
5d9f0ecf 867{
ab737e51
SC
868 while ( (*input_line_pointer++) && (*input_line_pointer != '\n') )
869 input_line_pointer++;
c593cf41
SC
870
871}
872void
873DEFUN(listing_list,(on),
874 unsigned int on)
875{
876 listing_tail->edict = on ? EDICT_LIST : EDICT_NOLIST;
5d9f0ecf 877}
3340f7e5 878
c593cf41 879
5d9f0ecf 880void
c593cf41 881DEFUN_VOID(listing_psize)
5d9f0ecf 882{
c593cf41
SC
883 paper_height = get_absolute_expression();
884
885 if (paper_height < 0 || paper_height > 1000)
886 {
887 paper_height = 0;
7143f43c 888 as_warn("strange paper height, set to no form");
c593cf41
SC
889 }
890 if (*input_line_pointer == ',')
891 {
892 input_line_pointer++;
893 paper_width = get_absolute_expression();
894 }
5d9f0ecf
SC
895}
896
897
898void
c593cf41
SC
899DEFUN(listing_title,(depth),
900 unsigned int depth)
a39116f1 901{
c593cf41
SC
902 char *start;
903 char *title;
904 unsigned int length;
905
906 SKIP_WHITESPACE();
907 if (*input_line_pointer=='\"') {
908 input_line_pointer++;
909 start = input_line_pointer;
910
911 while (*input_line_pointer)
912 {
913 if (*input_line_pointer == '\"')
914 {
915 length = input_line_pointer - start;
916 title = malloc(length + 1);
917 memcpy(title, start, length);
918 title[length] = 0;
919 listing_tail->edict = depth ? EDICT_SBTTL : EDICT_TITLE;
920 listing_tail->edict_arg = title;
921 input_line_pointer++;
922 demand_empty_rest_of_line();
923 return;
3340f7e5 924 }
c593cf41
SC
925 else if (*input_line_pointer == '\n')
926 {
927 as_bad("New line in title");
928 demand_empty_rest_of_line();
929 return;
3340f7e5 930 }
c593cf41
SC
931 else
932 {
933 input_line_pointer++;
934 }
935 }
936 }
937 else
938 {
939 as_bad("expecting title in quotes");
940 }
941}
942
5d9f0ecf
SC
943
944
945void
c593cf41
SC
946DEFUN(listing_source_line,(line),
947 unsigned int line)
5d9f0ecf 948{
c593cf41
SC
949 new_frag();
950 listing_tail->hll_line = line;
951 new_frag();
952
953}
5d9f0ecf 954
c593cf41
SC
955void
956DEFUN(listing_source_file,(file),
957 char *file)
958{
959 listing_tail->hll_file = file_info(file);
960}
5d9f0ecf 961
b3ca913f 962
c593cf41
SC
963
964#else
965
966
967/* Dummy functions for when compiled without listing enabled */
968
969void
970DEFUN_VOID(listing_flags)
971{
972 s_ignore();
973}
974
975void DEFUN_VOID(listing_list)
b3ca913f 976{
c593cf41
SC
977 s_ignore();
978}
979
980void DEFUN_VOID(listing_eject)
981{
982 s_ignore();
983}
20a88218 984void DEFUN_VOID(listing_psize)
c593cf41
SC
985{
986 s_ignore();
987}
b3ca913f 988
c593cf41
SC
989void DEFUN(listing_title, (depth),
990unsigned int depth)
991{
992 s_ignore();
993}
b3ca913f 994void
c593cf41
SC
995DEFUN(listing_file,(name),
996char *name)
b3ca913f 997{
c593cf41
SC
998
999}
1000
1001void DEFUN(listing_newline,(name),
1002char *name)
1003{
1004
b3ca913f
SC
1005}
1006
c593cf41
SC
1007void DEFUN(listing_source_line,(n),
1008unsigned int n)
1009{
1010
1011}
1012void DEFUN(listing_source_file, (n),
1013char *n)
1014{
1015
1016}
1017
1018
1019
1020#endif
b3ca913f 1021
This page took 0.086903 seconds and 4 git commands to generate.