Annotation of 41BSD/lib/libpc/ERROR.c, revision 1.1.1.1

1.1       root        1: /* Copyright (c) 1979 Regents of the University of California */
                      2: 
                      3: static char sccsid[] = "@(#)ERROR.c 1.1 10/29/80";
                      4: 
                      5: #include       "stdio.h"
                      6: #include       "signal.h"
                      7: #include       "h01errs.h"
                      8: 
                      9: /*
                     10:  * Routine ERROR is called from the runtime library when a runtime error
                     11:  * occurs. Its arguments are the internal number of the error which occurred,
                     12:  * and an error specific piece of error data. The error file is constructed
                     13:  * from errdata by the makefile using the editor script make.ed1.
                     14:  */
                     15: ERROR(errnum, errdata)
                     16: 
                     17:        long            errnum;
                     18:        union cvt {
                     19:                long    longdat;
                     20:                char    *strngdat;
                     21:                double  dbldat;
                     22:        } errdata;
                     23: {
                     24:        PFLUSH();
                     25:        fputc('\n',stderr);
                     26:        SETRACE();
                     27:        switch (errnum) {
                     28:        case ECHR:
                     29:                fprintf(stderr, "Argument to chr of %d is out of range\n"
                     30:                        ,errdata.longdat);
                     31:                return(errdata.longdat);
                     32:        case EHALT:
                     33:                fputs("Call to procedure halt\n",stderr);
                     34:                PCEXIT(0);
                     35:        case ENILPTR:
                     36:                fputs("Pointer value out of legal range\n",stderr);
                     37:                return(0);
                     38:        case EPASTEOF:
                     39:                fprintf(stderr,"%s: Tried to read past end of file\n"
                     40:                        ,errdata.strngdat);
                     41:                return(0);
                     42:        case EREADIT:
                     43:                fprintf(stderr,"%s: Attempt to read, but open for writing\n"
                     44:                        ,errdata.strngdat);
                     45:                return(0);
                     46:        case EWRITEIT:
                     47:                fprintf(stderr,"%s: Attempt to write, but open for reading\n"
                     48:                        ,errdata.strngdat);
                     49:                return(0);
                     50:        case ECLOSE:
                     51:                fprintf(stderr,"%s: Close failed\n",errdata.strngdat);
                     52:                return(0);
                     53:        case ELLIMIT:
                     54:                fprintf(stderr,"%s: Line limit exceeded\n",errdata.strngdat);
                     55:                return(0);
                     56:        case ESQRT:
                     57:                fprintf(stderr,"Negative argument of %E to sqrt\n"
                     58:                        ,errdata.dbldat);
                     59:                return(errdata.dbldat);
                     60:        case EREFINAF:
                     61:                fprintf(stderr,"%s: ",errdata.strngdat);
                     62:        case ENOFILE:
                     63:                fputs("Reference to an inactive file\n",stderr);
                     64:                return(0);
                     65:        case EWRITE:
                     66:                fputs("Could not write to ",stderr);
                     67:                perror(errdata.strngdat);
                     68:                return(0);
                     69:        case EOPEN:
                     70:                fputs("Could not open ",stderr);
                     71:                perror(errdata.strngdat);
                     72:                return(0);
                     73:        case ECREATE:
                     74:                fputs("Could not create ",stderr);
                     75:                perror(errdata.strngdat);
                     76:                return(0);
                     77:        case EREMOVE:
                     78:                fputs("Could not remove ",stderr);
                     79:                perror(errdata.strngdat);
                     80:                return(0);
                     81:        case ESEEK:
                     82:                fputs("Could not reset ",stderr);
                     83:                perror(errdata.strngdat);
                     84:                return(0);
                     85:        case ENAMESIZE:
                     86:                fprintf(stderr,"%s: File name too long\n",errdata.strngdat);
                     87:                return(0);
                     88:        case ELN:
                     89:                fprintf(stderr,"Non-positive argument of %E to ln\n"
                     90:                        ,errdata.dbldat);
                     91:                return(errdata.dbldat);
                     92:        case EBADINUM:
                     93:                fprintf(stderr,"%s: Bad data found on integer read\n"
                     94:                        ,errdata.strngdat);
                     95:                return(0);
                     96:        case EBADFNUM:
                     97:                fprintf(stderr,"%s: Bad data found on real read\n"
                     98:                        ,errdata.strngdat);
                     99:                return(0);
                    100:        case ENUMNTFD:
                    101:                fprintf(stderr,
                    102:                        "Unknown name \"%s\" found on enumerated type read\n",
                    103:                        errdata.strngdat);
                    104:                return(0);
                    105:        case ENAMRNG:
                    106:                fprintf(stderr,
                    107:                        "Enumerated type value of %d is out of range on output\n",
                    108:                        errdata.longdat);
                    109:                return(errdata.longdat);
                    110:        case EFMTSIZE:
                    111:                fprintf(stderr,"Negative format width: %d\n",errdata.longdat);
                    112:                return(0);
                    113:        case EGOTO:
                    114:                fputs("Active frame not found in non-local goto\n", stderr);
                    115:                return(0);
                    116:        case ECASE:
                    117:                fprintf(stderr,"Label of %d not found in case\n"
                    118:                        ,errdata.longdat);
                    119:                return(errdata.longdat);
                    120:        case EOUTOFMEM:
                    121:                fputs("Ran out of memory\n",stderr);
                    122:                return(0);
                    123:        case ECTLWR:
                    124:                fprintf(stderr, "Range lower bound of %d out of set bounds\n",
                    125:                        errdata.longdat);
                    126:                return(0);
                    127:        case ECTUPR:
                    128:                fprintf(stderr, "Range upper bound of %d out of set bounds\n",
                    129:                        errdata.longdat);
                    130:                return(0);
                    131:        case ECTSNG:
                    132:                fprintf(stderr, "Value of %d out of set bounds\n",
                    133:                        errdata.longdat);
                    134:                return(0);
                    135:        case ENARGS:
                    136:                if (errdata.longdat < 0)
                    137:                        fprintf(stderr,
                    138:                                "There were %d too few arguments to formal routine\n",
                    139:                                -errdata.longdat);
                    140:                else
                    141:                        fprintf(stderr,
                    142:                                "There were %d too many arguments to formal routine\n",
                    143:                                errdata.longdat);
                    144:                return(0);
                    145:        case EARGV:
                    146:                fprintf(stderr,"Argument to argv of %d is out of range\n"
                    147:                        ,errdata.longdat);
                    148:                return(errdata.longdat);
                    149:        case EPACK:
                    150:                fprintf(stderr,"i = %d: Bad i to pack(a,i,z)\n"
                    151:                        ,errdata.longdat);
                    152:                return(errdata.longdat);
                    153:        case EUNPACK:
                    154:                fprintf(stderr,"i = %d: Bad i to unpack(z,a,i)\n"
                    155:                        ,errdata.longdat);
                    156:                return(errdata.longdat);
                    157:        case ERANGE:
                    158:                fprintf(stderr,"Value of %d is out of range\n",errdata.longdat);
                    159:                return(errdata.longdat);
                    160:        case ESUBSC:
                    161:                fprintf(stderr,"Subscript value of %d is out of range\n"
                    162:                        ,errdata.longdat);
                    163:                return(errdata.longdat);
                    164:        case EASRT:
                    165:                fprintf(stderr,"Assertion failed: %s\n",errdata.strngdat);
                    166:                return(0);
                    167:        case ESTLIM:
                    168:                fprintf(stderr,
                    169:                        "Statement count limit exceeded, %d statements executed\n",
                    170:                        errdata.longdat);
                    171:                return(errdata.longdat);
                    172:        default:
                    173:                fputs("Panic: unknown error\n",stderr);
                    174:                return(0);
                    175:        }
                    176: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.