home *** CD-ROM | disk | FTP | other *** search
- #include <stdio.h>
- #include <stdlib.h>
- #include <ctype.h>
- #include <string.h>
- #include <assert.h>
-
- #ifndef unix
- #include <stdarg.h>
- #endif
- #include "glepro.h"
- int gprint_send(char *s);
- int g_message(char *s);
- char *line(int i);
- #define false 0
- #define true (!false)
- int this_line;
- int last_line;
- extern int trace_on;
- int gprint_cr;
- extern int ngerror;
- #ifdef unix
- void gprint_do(char *output)
- {
- char output2[199];
- char output3[99];
- int len;
-
- output[80]=0;
- output2[0] = 0;
- if (!gprint_cr) {
- ngerror++;
- if (last_line != this_line && !trace_on) {
- sprintf(output2,"=== %s\n",line(this_line));
- gprint_send(output2);
- }
- last_line = this_line;
- sprintf(output2,"%d: ",this_line);
- gprint_cr = true;
- }
- output[80] = 0;
- strcat(output2,output);
- gprint_send(output2);
- scr_refresh();
- }
- #else
- void gprint(va_list arg_list, ...)
- /* Prints an error message */
- {
- va_list arg_ptr;
- char *format;
- char output[281];
- char output2[199];
- char output3[99];
- int len;
-
- va_start(arg_ptr, arg_list);
- format = arg_list;
- vsprintf(output, format, arg_ptr);
- output[80]=0;
- output2[0] = 0;
- if (!gprint_cr) {
- ngerror++;
- if (last_line != this_line && !trace_on) {
- sprintf(output2,"=== %s\n",line(this_line));
- gprint_send(output2);
- }
- last_line = this_line;
- sprintf(output2,"%d: ",this_line);
- gprint_cr = true;
- }
- output[80] = 0;
- strcat(output2,output);
- gprint_send(output2);
- }
- #endif
- char *(*etxt)[];
- int netxt;
- gprint_send(char *ss)
- {
- int i;
- static char buff[180];
- char *s,*t;
- if (strlen(ss) + strlen(buff) > 170) buff[0] = 0;
- strcat(buff,ss);
- if (etxt==0) etxt = myallocz(70*4);
- loop: s = &buff[0];
- while (*s != 0) {
- if (*s == '\n') {
- gprint_cr = false;
- *s = 0;
- g_message(buff);
- if (netxt<50) {
- netxt++;
- if ((*etxt)[netxt]!=NULL) myfree((*etxt)[netxt]);
- (*etxt)[netxt] = sdup(buff);
- }
- memmove(buff,s+1,strlen(s+1)+1);
- goto loop;
- }
- s++;
- }
- }
-