3 A non-connected live-range not caught by the live-range splitter resulted
4 in an invalid register allocation and an assertion failure in code generation.
9 #pragma disable_warning 84
10 #pragma disable_warning 85
18 struct _bstdio_file
{int i
;};
19 typedef struct _bstdio_file
FILE;
21 int bfprintf(FILE *_bstream
, const char *__fmt
, ...)
26 int bprintf(const char *_bfmt
, ...)
31 FILE *__fopen(const char *_bpath
, int _bfd
, FILE * _bstream
, const char *_bmode
)
36 #define fopen(__file, __mode) __fopen((__file), -1, (FILE*)0, (__mode))
38 char *bgetenv(char *__name
)
43 char *bfgets(char *_bs
, size_t _bsize
, FILE *_bstream
)
50 void err(int _beval
, const char *_bfmt
, ...)
54 void errx(int _beval
, const char *_bfmt
, ...)
58 #if !defined( __SDCC_pdk14) && !defined( __SDCC_pdk15) // Lack of memory
67 enum {NONE
, DAY
, WEEK
, MONTH
} mflag
;
69 #define CALFILE "/.calendar"
71 int pnmatch(const char *s
, const char *p
, int unanch
)
110 int date(int day
, int month
, int year
)
119 int m(int argc
, char *argv
[])
121 #if !(defined (__SDCC_mcs51) && defined (__SDCC_MODEL_SMALL)) && !defined(__SDCC_pdk14) && !defined(__SDCC_pdk15) // Not enough memory
122 #if !(defined (__SDCC_mcs51) && (defined (__SDCC_MODEL_LARGE) || defined (__SDCC_MODEL_HUGE))) // build failure
132 int thismonth
, thisday
, thisyear
;
137 mflag
= NONE
; /* Default to no match */
139 for (arg
= 1; arg
< argc
; arg
++) { /* Read option string */
149 filename
[arg
-1] = ++cp
;
165 bfprintf(bstderr
, "%s: unrecognized option '%c'\n", argv0
, *cp
);
176 for (arg
= 0; arg
< nfiles
; arg
++ ) {
177 if ((fp
[arg
] = fopen(filename
[arg
], "r")) == NULL
)
178 bfprintf(bstderr
, "cannot open file %s\n", filename
[arg
]);
183 err(1, "cannot open any files specified");
188 if ((hp
= bgetenv("HOME")) == NULL
)
189 errx(1, "can't find my way back HOME");
190 filename
[0] = malloc(strlen(hp
) + strlen(CALFILE
) + 1);
191 if (filename
[0] == NULL
)
192 errx(1, "out of memory");
193 strcpy(filename
[0], hp
);
194 strcat(filename
[0], CALFILE
);
195 if ((fp
[0] = fopen(filename
[0], "r")) == NULL
)
196 err(1, "cannot open file $HOME/.calendar");
199 * Find match condition from options or current date
203 matchdate
= current(0);
207 if (*matchstr
== '\0')
208 matchdate
= current(0);
210 strncpy(CurLine
, matchstr
, sizeof(CurLine
));
211 CurLinep
= &CurLine
[0];
212 if ((thismonth
= findmon1()) == -1)
213 errx(1, "invalid month in match date");
214 if ((thisday
= findday()) == -1)
215 errx(1, "invalid day in match date");
216 if ((thisyear
= findyear()) == -1)
217 thisyear
= current(1);
218 matchdate
= date(thisday
, thismonth
, thisyear
);
222 if (*matchstr
== '\0')
223 matchdate
= current(2);
225 strncpy(CurLine
, matchstr
, sizeof(CurLine
));
226 CurLinep
= &CurLine
[0];
227 if ((matchdate
= findmon2()) == -1)
228 errx(1, "invalid month in match date");
233 * Read the calendar files, print matched lines.
235 for (arg
= 0; arg
< nfiles
; arg
++) {
238 while ((thisline
= bfgets(CurLine
,sizeof(CurLine
),fp
[arg
]))!=NULL
) {
239 CurLinep
= &CurLine
[0];
241 if ((atsign
= strchr(CurLinep
, '@')) != NULL
)
242 advance
= atoi(atsign
+ 1);
243 if ((thismonth
= findmon3()) == -1)
245 if ((thisday
= findday()) == -1)
247 if ((thisyear
= findyear()) == -1)
248 thisyear
= current(1);
249 thisdate
= date(thisday
, thismonth
, thisyear
);
250 if (thisdate
>= matchdate
&&
251 thisdate
<= matchdate
+ advance
)
252 bprintf("%s", thisline
);
253 else switch (mflag
) {
256 if (thisdate
== matchdate
||
257 thisdate
== matchdate
+ 1 ||
258 thisdate
== matchdate
+ 2 ||
259 thisdate
== matchdate
+ 3)
260 bprintf("%s", thisline
);
262 if (thisdate
== matchdate
||
263 thisdate
== matchdate
+ 1 ||
264 thisdate
== matchdate
+ 2)
265 bprintf("%s", thisline
);
266 if (0 <= wday
&& wday
< 6)
267 if (thisdate
== matchdate
||
268 thisdate
== matchdate
+ 1)
269 bprintf("%s", thisline
);
272 if (thisdate
== matchdate
)
273 bprintf("%s", thisline
);
276 if (matchdate
<= thisdate
&&
277 thisdate
<= matchdate
+7)
278 bprintf("%s", thisline
);
281 if (thismonth
== matchdate
)
282 bprintf("%s", thisline
);