[BACK]Return to error.h CVS log [TXT][DIR] Up to [local] / src / usr.bin / error

Annotation of src/usr.bin/error/error.h, Revision 1.7

1.7     ! millert     1: /*     $OpenBSD: error.h,v 1.6 2002/06/14 21:35:00 todd Exp $  */
1.1       deraadt     2: /*     $NetBSD: error.h,v 1.3 1995/09/02 06:15:25 jtc Exp $    */
                      3:
                      4: /*
                      5:  * Copyright (c) 1980, 1993
                      6:  *     The Regents of the University of California.  All rights reserved.
                      7:  *
                      8:  * Redistribution and use in source and binary forms, with or without
                      9:  * modification, are permitted provided that the following conditions
                     10:  * are met:
                     11:  * 1. Redistributions of source code must retain the above copyright
                     12:  *    notice, this list of conditions and the following disclaimer.
                     13:  * 2. Redistributions in binary form must reproduce the above copyright
                     14:  *    notice, this list of conditions and the following disclaimer in the
                     15:  *    documentation and/or other materials provided with the distribution.
1.7     ! millert    16:  * 3. Neither the name of the University nor the names of its contributors
1.1       deraadt    17:  *    may be used to endorse or promote products derived from this software
                     18:  *    without specific prior written permission.
                     19:  *
                     20:  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
                     21:  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
                     22:  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
                     23:  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
                     24:  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
                     25:  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
                     26:  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
                     27:  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
                     28:  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
                     29:  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
                     30:  * SUCH DAMAGE.
                     31:  *
                     32:  *     @(#)error.h     8.1 (Berkeley) 6/6/93
                     33:  */
                     34:
                     35: typedef        int     boolean;
                     36: #define        reg     register
                     37:
                     38: #define        TRUE    1
                     39: #define        FALSE   0
                     40:
                     41: #define        true    1
                     42: #define        false   0
                     43: /*
                     44:  *     Descriptors for the various languages we know about.
                     45:  *     If you touch these, also touch lang_table
                     46:  */
                     47: #define        INUNKNOWN       0
                     48: #define        INCPP   1
                     49: #define        INCC    2
                     50: #define        INAS    3
                     51: #define        INLD    4
                     52: #define        INLINT  5
                     53: #define        INF77   6
                     54: #define        INPI    7
                     55: #define        INPC    8
                     56: #define        INFRANZ 9
                     57: #define        INLISP  10
                     58: #define        INVAXIMA        11
                     59: #define        INRATFOR        12
                     60: #define        INLEX   13
                     61: #define        INYACC  14
                     62: #define        INAPL   15
                     63: #define        INMAKE  16
                     64: #define        INRI    17
                     65: #define        INTROFF 18
                     66: #define        INMOD2  19
                     67:
                     68: extern int     language;
                     69: /*
                     70:  *     We analyze each line in the error message file, and
                     71:  *     attempt to categorize it by type, as well as language.
                     72:  *     Here are the type descriptors.
                     73:  */
                     74: typedef        int     Errorclass;
                     75:
                     76: #define        C_FIRST 0               /* first error category */
                     77: #define        C_UNKNOWN       0       /* must be zero */
                     78: #define        C_IGNORE        1       /* ignore the message; used for pi */
                     79: #define        C_SYNC          2       /* synchronization errors */
                     80: #define        C_DISCARD       3       /* touches dangerous files, so discard */
                     81: #define        C_NONSPEC       4       /* not specific to any file */
                     82: #define        C_THISFILE      5       /* specific to this file, but at no line */
                     83: #define        C_NULLED        6       /* refers to special func; so null */
                     84: #define        C_TRUE          7       /* fits into true error format */
                     85: #define        C_DUPL          8       /* sub class only; duplicated error message */
                     86: #define        C_LAST  9               /* last error category */
                     87:
                     88: #define        SORTABLE(x)     (!(NOTSORTABLE(x)))
                     89: #define        NOTSORTABLE(x)  (x <= C_NONSPEC)
                     90: /*
                     91:  *     Resources to count and print out the error categories
                     92:  */
                     93: extern char            *class_table[];
                     94: extern int             class_count[];
                     95:
                     96: #define        nunknown        class_count[C_UNKNOWN]
                     97: #define        nignore         class_count[C_IGNORE]
                     98: #define        nsyncerrors     class_count[C_SYNC]
                     99: #define        ndiscard        class_count[C_DISCARD]
                    100: #define        nnonspec        class_count[C_NONSPEC]
                    101: #define        nthisfile       class_count[C_THISFILE]
                    102: #define        nnulled         class_count[C_NULLED]
                    103: #define        ntrue           class_count[C_TRUE]
                    104: #define        ndupl           class_count[C_DUPL]
                    105:
                    106: /* places to put the error complaints */
                    107:
                    108: #define        TOTHEFILE       1       /* touch the file */
                    109: #define        TOSTDOUT        2       /* just print them out (ho-hum) */
                    110:
                    111: FILE   *errorfile;     /* where error file comes from */
                    112: FILE   *queryfile;     /* where the query responses from the user come from*/
                    113:
                    114: extern char    *currentfilename;
                    115: extern char    *scriptname;
                    116:
                    117: extern boolean query;
                    118: extern boolean terse;
                    119: int    inquire();                      /* inquire for yes/no */
                    120: /*
                    121:  *     codes for inquire() to return
                    122:  */
                    123: #define        Q_NO    1                       /* 'N' */
                    124: #define        Q_no    2                       /* 'n' */
                    125: #define        Q_YES   3                       /* 'Y' */
                    126: #define        Q_yes   4                       /* 'y' */
                    127:
                    128: int    probethisfile();
                    129: /*
                    130:  *     codes for probethisfile to return
                    131:  */
                    132: #define        F_NOTEXIST      1
                    133: #define        F_NOTREAD       2
                    134: #define        F_NOTWRITE      3
                    135: #define        F_TOUCHIT       4
                    136:
                    137: /*
                    138:  *     Describes attributes about a language
                    139:  */
                    140: struct lang_desc{
                    141:        char    *lang_name;
                    142:        char    *lang_incomment;        /* one of the following defines */
                    143:        char    *lang_outcomment;       /* one of the following defines */
                    144: };
                    145: extern struct lang_desc lang_table[];
                    146:
                    147: #define        CINCOMMENT      "/*###"
                    148: #define        COUTCOMMENT     "%%%*/\n"
                    149: #define        FINCOMMENT      "C###"
                    150: #define        FOUTCOMMENT     "%%%\n"
                    151: #define        NEWLINE         "%%%\n"
                    152: #define        PIINCOMMENT     "(*###"
                    153: #define        PIOUTCOMMENT    "%%%*)\n"
                    154: #define        LISPINCOMMENT   ";###"
                    155: #define        ASINCOMMENT     "####"
                    156: #define        RIINCOMMENT     CINCOMMENT
                    157: #define        RIOUTCOMMENT    COUTCOMMENT
                    158: #define        TROFFINCOMMENT  ".\\\"###"
                    159: #define        TROFFOUTCOMMENT NEWLINE
                    160: #define        MOD2INCOMMENT   "(*###"
                    161: #define        MOD2OUTCOMMENT  "%%%*)\n"
                    162: /*
1.6       todd      163:  *     Defines and resources for determining if a given line
1.1       deraadt   164:  *     is to be discarded because it refers to a file not to
                    165:  *     be touched, or if the function reference is to a
                    166:  *     function the user doesn't want recorded.
                    167:  */
                    168:
                    169: #define        ERRORNAME       "/.errorrc"
                    170: int    nignored;
                    171: char   **names_ignored;
                    172: /*
                    173:  *     Structure definition for a full error
                    174:  */
                    175: typedef struct edesc   Edesc;
                    176: typedef        Edesc   *Eptr;
                    177:
                    178: struct edesc{
1.6       todd      179:        Eptr    error_next;             /* linked together*/
1.1       deraadt   180:        int     error_lgtext;           /* how many on the right hand side*/
                    181:        char    **error_text;           /* the right hand side proper*/
                    182:        Errorclass      error_e_class;  /* error category of this error*/
                    183:        Errorclass      error_s_class;  /* sub descriptor of error_e_class*/
                    184:        int     error_language;         /* the language for this error*/
                    185:        int     error_position;         /* oridinal position */
                    186:        int     error_line;             /* discovered line number*/
                    187:        int     error_no;               /* sequence number on input */
                    188: };
                    189: /*
                    190:  *     Resources for the true errors
                    191:  */
                    192: extern int     nerrors;
                    193: extern Eptr    er_head;
                    194: extern Eptr    *errors;
                    195: /*
                    196:  *     Resources for each of the files mentioned
                    197:  */
                    198: extern int     nfiles;
                    199: extern Eptr    **files;        /* array of pointers into errors*/
                    200: boolean        *touchedfiles;                  /* which files we touched */
                    201: /*
1.4       deraadt   202:  *     The language the compilation is in, as intuited from
1.1       deraadt   203:  *     the flavor of error messages analyzed.
                    204:  */
1.4       deraadt   205: extern int     language;
1.1       deraadt   206: extern char    *currentfilename;
                    207: /*
                    208:  *     Functional forwards
                    209:  */
                    210: char   *Calloc();
                    211: char   *strsave();
                    212: char   *clobberfirst();
                    213: char   lastchar();
                    214: char   firstchar();
                    215: char   next_lastchar();
                    216: char   **wordvsplice();
                    217: int    wordvcmp();
                    218: boolean        persperdexplode();
1.5       deraadt   219:
1.1       deraadt   220: /*
                    221:  *     Printing hacks
                    222:  */
                    223: char   *plural(), *verbform();
1.5       deraadt   224:
                    225: void   getignored(char *);
                    226: void   eaterrors(int *, Eptr **);
                    227: void   printerrors(boolean, int, Eptr []);
                    228: void   wordvbuild(char *, int *, char ***);
                    229: Errorclass discardit(Eptr);
                    230: void   erroradd(int, char **, Errorclass, Errorclass);
                    231: void   arrayify(int *, Eptr **, Eptr);
                    232: Errorclass catchall(void);
                    233: char * substitute(char *, char, char);
                    234: void   clob_last(char *, char);
                    235: int    f77(void);
                    236: void   wordvprint(FILE *, int, char *[]);
                    237: void   wordvbuild(char *, int *, char ***);
                    238: void   findfiles(int, Eptr *, int *, Eptr ***);
                    239: boolean        touchfiles(int, Eptr **, int *, char ***);
                    240: void   forkvi(int, char **);
                    241: void   try(char *, int, char **);
                    242: void   filenames(int, Eptr **);
                    243: int    countfiles(Eptr *);
                    244: void   errorprint(FILE *, Eptr, boolean);
                    245: void   hackfile(char *, Eptr **, int, int);
                    246: void   execvarg(int, int *, char ***);
                    247: int    nopertain(Eptr **);
                    248: int    oktotouch(char *);
                    249: boolean        preview(char *, int, Eptr **, int);
                    250: int    settotouch(char *);
                    251: void   diverterrors(char *, int, Eptr **, int, boolean, int);
                    252: int    writetouched(int);
                    253: boolean        edit(char *);
                    254: void   insert(int);
                    255: void   text(Eptr, boolean);
                    256: int    mustoverwrite(FILE *, FILE *);
                    257: int    mustwrite(char *, int, FILE *);
                    258: int    position(char *, char);