Commit | Line | Data |
79072805 |
1 | /* $RCSfile: op.c,v $$Revision: 4.1 $$Date: 92/08/07 17:19:16 $ |
2 | * |
3 | * Copyright (c) 1991, Larry Wall |
4 | * |
5 | * You may distribute under the terms of either the GNU General Public |
6 | * License or the Artistic License, as specified in the README file. |
7 | * |
8 | * $Log: op.c,v $ |
9 | * Revision 4.1 92/08/07 17:19:16 lwall |
10 | * Stage 6 Snapshot |
11 | * |
12 | * Revision 4.0.1.5 92/06/08 12:00:39 lwall |
13 | * patch20: the switch optimizer didn't do anything in subroutines |
14 | * patch20: removed implicit int declarations on funcions |
15 | * |
16 | * Revision 4.0.1.4 91/11/11 16:29:33 lwall |
17 | * patch19: do {$foo ne "bar";} returned wrong value |
18 | * patch19: some earlier patches weren't propagated to alternate 286 code |
19 | * |
20 | * Revision 4.0.1.3 91/11/05 16:07:43 lwall |
21 | * patch11: random cleanup |
22 | * patch11: "foo\0" eq "foo" was sometimes optimized to true |
23 | * patch11: foreach on null list could spring memory leak |
24 | * |
25 | * Revision 4.0.1.2 91/06/07 10:26:45 lwall |
26 | * patch4: new copyright notice |
27 | * patch4: made some allowances for "semi-standard" C |
28 | * |
29 | * Revision 4.0.1.1 91/04/11 17:36:16 lwall |
30 | * patch1: you may now use "die" and "caller" in a signal handler |
31 | * |
32 | * Revision 4.0 91/03/20 01:04:18 lwall |
33 | * 4.0 baseline. |
34 | * |
35 | */ |
36 | |
37 | #include "EXTERN.h" |
38 | #include "perl.h" |
39 | |
8990e307 |
40 | #ifdef STANDARD_C |
41 | # include <stdarg.h> |
42 | #else |
43 | # ifdef I_VARARGS |
44 | # include <varargs.h> |
45 | # endif |
79072805 |
46 | #endif |
47 | |
48 | void deb_growlevel(); |
49 | |
8990e307 |
50 | #if !defined(STANDARD_C) && !defined(I_VARARGS) |
51 | |
52 | /* |
53 | * Fallback on the old hackers way of doing varargs |
54 | */ |
55 | |
79072805 |
56 | /*VARARGS1*/ |
8990e307 |
57 | void |
58 | deb(pat,a1,a2,a3,a4,a5,a6,a7,a8) |
59 | char *pat; |
79072805 |
60 | { |
61 | register I32 i; |
62 | |
8990e307 |
63 | fprintf(stderr,"(%s:%ld)\t", |
64 | SvPVX(GvSV(curcop->cop_filegv)),(long)curcop->cop_line); |
79072805 |
65 | for (i=0; i<dlevel; i++) |
66 | fprintf(stderr,"%c%c ",debname[i],debdelim[i]); |
67 | fprintf(stderr,pat,a1,a2,a3,a4,a5,a6,a7,a8); |
68 | } |
8990e307 |
69 | |
70 | #else /* !defined(STANDARD_C) && !defined(I_VARARGS) */ |
71 | |
72 | # ifdef STANDARD_C |
73 | void |
74 | deb(char *pat, ...) |
79072805 |
75 | # else |
76 | /*VARARGS1*/ |
8990e307 |
77 | void |
78 | deb(pat, va_alist) |
79 | char *pat; |
80 | va_dcl |
81 | # endif |
79072805 |
82 | { |
83 | va_list args; |
79072805 |
84 | register I32 i; |
85 | |
8990e307 |
86 | fprintf(stderr,"(%s:%ld)\t", |
87 | SvPVX(GvSV(curcop->cop_filegv)),(long)curcop->cop_line); |
79072805 |
88 | for (i=0; i<dlevel; i++) |
89 | fprintf(stderr,"%c%c ",debname[i],debdelim[i]); |
90 | |
8990e307 |
91 | # if STANDARD_C |
92 | va_start(args, pat); |
93 | # else |
94 | va_start(args); |
95 | # endif |
79072805 |
96 | (void) vfprintf(stderr,pat,args); |
97 | va_end( args ); |
98 | } |
8990e307 |
99 | #endif /* !defined(STANDARD_C) && !defined(I_VARARGS) */ |
79072805 |
100 | |
101 | void |
102 | deb_growlevel() |
103 | { |
104 | dlmax += 128; |
105 | Renew(debname, dlmax, char); |
106 | Renew(debdelim, dlmax, char); |
107 | } |
108 | |
109 | I32 |
110 | debstackptrs() |
111 | { |
112 | fprintf(stderr, "%8lx %8lx %8ld %8ld %8ld\n", |
113 | stack, stack_base, *markstack_ptr, stack_sp-stack_base, stack_max-stack_base); |
114 | fprintf(stderr, "%8lx %8lx %8ld %l8d %8ld\n", |
115 | mainstack, AvARRAY(stack), mainstack, AvFILL(stack), AvMAX(stack)); |
116 | return 0; |
117 | } |
118 | |
119 | I32 |
120 | debstack() |
121 | { |
122 | register I32 i; |
123 | I32 markoff = markstack_ptr > markstack ? *markstack_ptr : -1; |
124 | |
125 | fprintf(stderr, " =>"); |
126 | if (stack_base[0] || stack_sp < stack_base) |
127 | fprintf(stderr, " [STACK UNDERFLOW!!!]\n"); |
128 | for (i = 1; i <= 30; i++) { |
129 | if (stack_sp >= &stack_base[i]) |
130 | { |
131 | fprintf(stderr, "\t%-4s%s%s", SvPEEK(stack_base[i]), |
132 | markoff == i ? " [" : "", |
133 | stack_sp == &stack_base[i] ? |
134 | (markoff == i ? "]" : " ]") : ""); |
135 | } |
136 | } |
137 | fprintf(stderr, "\n"); |
138 | return 0; |
139 | } |