#!/bin/sh # # This is a shell archive. To extract its contents, # execute this file with /bin/sh to create the file(s): # # README dbxref.c dbxref.h # # This shell archive created: Tue Dec 29 09:07:35 EST 1992 # echo "Extracting file README" sed -e 's/^X//' <<\SHAR_EOF > README XProduces a cross-reference I4GL code. X XFor usage, run without any parameters. X XOutput is in the form X X Name [Defn] (Freq) #, #, ... X X [Defn] indicates where the funxtion/variable was defined X (Freq) is the # times used X # are line line-numbers. X XWatch out for the names of your variables ... if you use on that is Xa reserved word in *any* Informix product, chances are things won't Xwork too good! The program looks for (the absence) of these to determine Xif it is processing a "DEFINE" section. X XYou will need an ANSI C compiler XDeveloped under Ultrix 4.3 X XProblems/improvements: email to stuart@coral.cs.jcu.edu.au X X-SRK X SHAR_EOF if [ `wc -c < README` -ne 633 ] then echo "Lengths do not match -- Bad Copy of README" fi echo "Extracting file dbxref.c" sed -e 's/^X//' <<\SHAR_EOF > dbxref.c X/* This will parse a 4gl file, and create a cross-reference X * of user variables/functions/labels. X * X * Scope rules are applied to all variables X * X * Output is in the form X * X * Name [Defn] (Freq) #, #, ... X * X * where 'Name' is the variable/function/label X * 'Defn' is where a label or function is defined X * 'Freq' is the number of times used (excluding the line X * of defn in the case of labels or functions) X * # are lines numbers where used X * X * This program was inspired by Dave Snyder's "dbbeauty" program. X * X * Written by Stuart kemp (stuart@coral.cs.jcu.edu.au) X * Copyright 1992, All rights reserved X * X * This program is offered 'as is'; the author accepts no responsibility X * for any consequences of its use. X * X * May be freely distributed as long as this comment remains. You may NOT X * sell it, and don't claim you wrote it. X * X */ X X#include X#include X#include X#include X#include X X/* #define DEBUG */ X/* #define DEBUG1 */ X X#define TRUE 1 X#define FALSE 0 X X#define FLG_GLOBAL 0x0001 /* Global variable */ X#define FLG_LOCAL 0x0002 /* Local variable */ X#define FLG_FUNC 0x0004 /* Function call */ X#define FLG_LABEL 0x0008 /* Label */ X#define FLG_REPORT 0x0010 /* Report */ X#define FLG_CURSOR 0x0020 /* Cursor */ X#define FLG_TBLSCR 0x0040 /* A table or screen record */ X#define FLG_SCR 0x0040 /* Will try separate these one day :-) */ X#define FLG_TABLE 0x0040 X#define FLG_FIELD 0x0080 /* Part of a record/table/screen-array */ X#define FLG_WINDOW 0x0100 /* A window */ X#define FLG_UNKNOWN 0x0200 /* Unknown type */ X X#define FLG_MASK 0x0FFF X X#define STAY_DEFINE 0x4000 X#define FLG_INACTIVE 0x2000 /* Variable out of scope */ X#define DEFN_BIT 0x1000 /* Bit indicates a definition */ X#define IS_DEFN(x) ((x) & DEFN_BIT) X X#define DEFN_GLOBAL (FLG_GLOBAL | DEFN_BIT) X#define DEFN_LOCAL (FLG_LOCAL | DEFN_BIT) X#define DEFN_FUNC (FLG_FUNC | DEFN_BIT) X#define DEFN_LABEL (FLG_LABEL | DEFN_BIT) X#define DEFN_REPORT (FLG_REPORT | DEFN_BIT) X#define DEFN_UNKNOWN (FLG_UNKNOWN | DEFN_BIT) X X#define TOKEN_CONTROL 1 X#define TOKEN_DEFINE 2 X#define TOKEN_END 3 X#define TOKEN_FUNCTION 4 X#define TOKEN_GLOBAL 5 X#define TOKEN_INSERT 6 X#define TOKEN_INTO 7 X#define TOKEN_KEY 8 X#define TOKEN_LIKE 9 X#define TOKEN_RECORD 10 X#define TOKEN_REPORT 11 X#define TOKEN_SELECT 12 X#define TOKEN_SET 13 X#define TOKEN_WHERE 14 X X#include "dbxref.h" X X#define MAX_VAR_LEN 32 Xtypedef char VarType[MAX_VAR_LEN + 1]; Xtypedef short BOOLEAN; X X/* Definition records for each variable. X * There will be a separate definition record each time this X * variable appears in a DEFINE statement. X */ Xtypedef Xstruct _DefnRec X { unsigned DefnLine; /* Where defined */ X unsigned NumTimesUsed; /* # times this var used */ X unsigned Space; /* Space for this many refs */ X unsigned *LineNums; /* Lines #'s where used */ X unsigned Flags; /* Global, Local, Active, etc. */ X struct _DefnRec *Next; /* Next var with this name */ X } DefnRec; X X/* Header record. Has only the name, and pointers. X */ Xtypedef Xstruct _Entry X { VarType TheVar; /* var's name */ X struct _DefnRec *Defn; /* Definitions */ X struct _Entry *Next; /* Next var */ X } Entry; X Xtypedef char WordType[128]; X XFILE *fp; /* Input file */ XFILE *FpOut = stdout; /* Output file */ Xchar *OutFileName; /* Name of output file (default is stdout) */ XEntry *List = NULL; /* Start of linked list */ Xunsigned LineNo; /* Current line in input file */ Xunsigned FoundOn; /* Line where token found */ XBOOLEAN MultipleRefs; /* Show if used > 1 per line */ XBOOLEAN InDefine, InGlobal, InFunction, InParams; X Xvoid * Xxmalloc(unsigned Bytes) X{ X void *p = malloc(Bytes); X X if (p == NULL) X { fprintf(stderr, "malloc() failed\n"); X exit(-1); X } X X return(p); X} X Xvoid * Xxrealloc(void *OldPtr, unsigned Bytes) X{ X void *p = realloc(OldPtr, Bytes); X X if (p == NULL) X { fprintf(stderr, "realloc() failed\n"); X exit(-1); X } X X return(p); X} X X/* Searches for the named variable. If found, returns 0, X * otherwise 1, and the 'Behind' is set to the node just X * behind the one that was greater than this var X */ Xint XSearchForVar(VarType Var, Entry **Behind) X{ X Entry *p; X int Ans; X X *Behind = NULL; X for (p = List; p; p = p->Next) X { Ans = strcasecmp(p->TheVar, Var); X if (Ans >= 0) return(Ans); /* Current is >= search */ X *Behind = p; X } X X return(1); /* Not found in list */ X} X X/* Marks all 'local' variables as being inactive. X * Basically, this routine is called after each 'END FUNCTION' X */ Xvoid XAllInactive() X{ X Entry *p; X DefnRec *q; X X for (p = List; p; p = p->Next) X { for (q = p->Defn; q; q = q->Next) X if (q->Flags == DEFN_LOCAL || X q->Flags & FLG_LABEL) q->Flags |= FLG_INACTIVE; X } X} X X/* Adds a line-number reference to an existinf definition record. X * The given line-number will be added if it has not been used before, X * or if the user has explicitly requested that multiple references X * be reported. X */ Xvoid XAddLineNum(DefnRec *q, unsigned LineNum) X{ X if (MultipleRefs || q->NumTimesUsed == 0 || X q->LineNums[q->NumTimesUsed - 1] != LineNum) X { if (q->NumTimesUsed == q->Space) X { q->Space += 20; X q->LineNums = xrealloc(q->LineNums, q->Space * sizeof(unsigned)); X } X q->LineNums[q->NumTimesUsed++] = LineNum; X } X} X X/* Create and initialise a new definition record. X */ XDefnRec * XMakeDefnRec() X{ X DefnRec *q; X X q = xmalloc(sizeof(DefnRec)); /* New defn rec */ X q->LineNums = (unsigned*) xmalloc(20 * sizeof(unsigned)); X q->Space = 20; /* Place for references */ X q->DefnLine = 0; X q->Flags = 0; X q->NumTimesUsed = 0; X q->Next = NULL; X X return(q); X} X X/* Adds usage of a variable at specified line # X * The 'DefnType' specified either local or global var X */ XBOOLEAN XUseVariable(Entry *Head, unsigned Line, unsigned DefnType) X{ X DefnRec *q; X X#ifdef DEBUG X fprintf(stderr, "Use: `%s' Line: %d DefnType: %X ", X Head->TheVar, Line, DefnType); X#endif X X for (q = Head->Defn; q; q = q->Next) X { X#ifdef DEBUG X fprintf(stderr, " 0x%X(%u)", q->Flags, q->DefnLine); X#endif X if ((q->Flags == DefnType) && !(q->Flags & FLG_INACTIVE)) X { AddLineNum(q, Line); X#ifdef DEBUG X fputc('\n', stderr); fflush(stderr); X#endif X return(TRUE); X } X } X X#ifdef DEBUG X fputc('\n', stderr); fflush(stderr); X#endif X return(FALSE); X} X X/* Gets a header-node or the named token. X * If there is no header-node, one is created. X */ XEntry * XGetHeader(VarType NewVar) X{ X Entry *p, *Behind; X X if (SearchForVar(NewVar, &Behind)) /* NOT in list */ X { p = (Entry*) xmalloc(sizeof(Entry)); X strncpy(p->TheVar, NewVar, MAX_VAR_LEN); X *(p->TheVar + MAX_VAR_LEN) = 0; /* Safety! */ X p->Defn = NULL; X#ifdef DEBUG X fprintf(stderr, "Add header for `%s'\n", NewVar); fflush(stderr); X#endif X X if (Behind == NULL) X { p->Next = List; X List = p; X } X else X { p->Next = Behind->Next; X Behind->Next = p; X } X } X else X p = Behind ? Behind->Next : List; X X return(p); X} X X/* Used to add a local/global variable. X * Appends a new definition record X */ XDefnRec * XAddNode(VarType NewVar) X{ X Entry *p; X DefnRec *q, *r; X X p = GetHeader(NewVar); X X for (q = p->Defn; q && (q->Flags & FLG_INACTIVE); q = q->Next); X X if (!q) X { q = MakeDefnRec(); X X if (p->Defn) X { for (r = p->Defn; r->Next; r = r->Next); X r->Next = q; X } X else X p->Defn = q; X } X X return(q); X} X X/* Finds the 'active' definition for the specified variable of the X * given type. If no active record is found, then create one, and X * append it to the list. X * It is possible that this variable already exists and is of X * unknown type ... this entry will then be returned. X * For a variable, a this will NOT return the GLOBAL defn. X */ XDefnRec * XGetActive(Entry *p, unsigned Type) X{ X DefnRec *q, *r; X X for (q = p->Defn; q; q = q->Next) X { if (q->Flags & FLG_INACTIVE) continue; /* Out of scope */ X if (q->Flags & Type) break; /* Found it */ X if (q->Flags == DEFN_UNKNOWN) break; /* Determined later */ X } X X if (!q) X { q = MakeDefnRec(); X if (p->Defn) X { for (r = p->Defn; r->Next; r = r->Next); X r->Next = q; X } X else X p->Defn = q; X } X X return(q); X} X Xvoid XAddDefinition(VarType NewVar, unsigned Line, unsigned Flags) X{ X Entry *p; X DefnRec *q; X X#ifdef DEBUG X fprintf(stderr, " Add defn for `%s' Line: %u Flags: 0x%X\n", X NewVar, Line, Flags); fflush(stderr); X#endif X X switch (Flags) X { case DEFN_GLOBAL: X q = AddNode(NewVar); X q->DefnLine = Line; X q->Flags = DEFN_GLOBAL; X break; X X case DEFN_UNKNOWN: X p = GetHeader(NewVar); X q = GetActive(p, 0); X q->Flags = DEFN_UNKNOWN; X AddLineNum(q, Line); X break; X X case DEFN_LOCAL: X p = GetHeader(NewVar); X q = GetActive(p, InParams ? 0 : FLG_LOCAL); X q->Flags = DEFN_LOCAL; X if (InParams) X AddLineNum(q, Line); X else X q->DefnLine = Line; X break; X X case DEFN_LABEL: X case DEFN_FUNC: X p = GetHeader(NewVar); X q = GetActive(p, Flags & ~DEFN_BIT); X q->Flags = Flags; X q->DefnLine = Line; X break; X default: X fprintf(stderr, "UNKNOWN DEFINITION FOR `%s' TYPE: 0x%X\n", NewVar, Flags); X break; X } X} X Xvoid XAddEntry(VarType NewVar, char CharAfter, unsigned Line, unsigned Flags) X{ X Entry *p; X DefnRec *q; X static char CharBefore = 0; X X#ifdef DEBUG X fprintf(stderr, "AddEntry: `%s' type: 0x%X on line %u\n", X NewVar, Flags, Line); fflush(stderr); X#endif X X if (InParams) X AddDefinition(NewVar, Line, DEFN_LOCAL); X else X if (InDefine) X { X AddDefinition(NewVar, Line, !InFunction ? DEFN_GLOBAL : DEFN_LOCAL); X } X else X if (IS_DEFN(Flags)) X AddDefinition(NewVar, Line, Flags); X else X { p = GetHeader(NewVar); X switch (Flags & FLG_MASK) X { case 0: /* No explicit type */ X if (!UseVariable(p, Line, DEFN_LOCAL) && X !UseVariable(p, Line, DEFN_GLOBAL) && X !UseVariable(p, Line, DEFN_FUNC) && X !UseVariable(p, Line, FLG_CURSOR) && X !UseVariable(p, Line, FLG_TBLSCR) && X !UseVariable(p, Line, FLG_WINDOW) && X !UseVariable(p, Line, FLG_FIELD) && X !UseVariable(p, Line, DEFN_UNKNOWN)) X { X#ifdef DEBUG X fprintf(stderr, " Unknown token `%s' on line %u\n", NewVar, Line); X#endif X AddDefinition(NewVar, Line, DEFN_UNKNOWN); X } X break; X case FLG_FUNC: X case FLG_REPORT: X case FLG_LABEL: X case FLG_CURSOR: X case FLG_TBLSCR: X case FLG_FIELD: X case FLG_WINDOW: X q = GetActive(p, Flags & FLG_MASK); X q->Flags = Flags & FLG_MASK; X AddLineNum(q, Line); X break; X default: X fprintf(stderr, "AddEntry: Unknown `%s' type: 0x%X on line %u\n", X NewVar, Flags, Line); X break; X } X } X CharBefore = CharAfter; /* For next time */ X} X X/* Prints out 'variables' of certain type. X * Keep a count of the # bytes printed per line, so can do 'nice' output. X */ Xvoid XPrintType(unsigned Mask, unsigned Type) X{ X Entry *p; X DefnRec *q; X char Num[16]; X unsigned *i, j, Chars, Indent; X X for (p = List; p; p = p->Next) X for (q = p->Defn; q; q = q->Next) X if ((q->Flags & Mask) == Type) X { Chars = 13; X fprintf(FpOut, "%-13s", p->TheVar); X if (Type != FLG_UNKNOWN && X Type != FLG_WINDOW && X Type != FLG_TBLSCR && X Type != FLG_FIELD) X if (q->DefnLine) X { sprintf(Num, " [%4u]", q->DefnLine); X fputs(Num, FpOut); X Chars += strlen(Num); X } X else X { fputs(" ", FpOut); X Chars += 7; X } X sprintf(Num, " (%2u)", q->NumTimesUsed); X fputs(Num, FpOut); X Chars += strlen(Num); X Indent = Chars; /* Indent on subsequent lines */ X X for (i = q->LineNums, j = q->NumTimesUsed; j > 0; j--, i++) X { if (Chars > 75) X { Chars = Indent; X fprintf(FpOut, "\n%*s", Indent, " "); X } X sprintf(Num, " %u", *i); X fputs(Num, FpOut); X Chars += strlen(Num); X } X fputc('\n', FpOut); X } X} X Xvoid XPrintList() X{ X fprintf(FpOut, "GLOBAL VARIABLES\n"); X PrintType(FLG_MASK, FLG_GLOBAL); X X fprintf(FpOut, "\nLOCAL VARIABLES\n"); X PrintType(FLG_MASK, FLG_LOCAL); X X fprintf(FpOut, "\nUNKNOWN VARIABLES\n"); X PrintType(FLG_MASK, FLG_UNKNOWN); X X fprintf(FpOut, "\nFUNCTION NAMES\n"); X PrintType(FLG_MASK, FLG_FUNC); X X fprintf(FpOut, "\nLABELS\n"); X PrintType(FLG_MASK, FLG_LABEL); X X fprintf(FpOut, "\nCURSORS\n"); X PrintType(FLG_MASK, FLG_CURSOR); X X fprintf(FpOut, "\nREPORTS\n"); X PrintType(FLG_MASK, FLG_REPORT); X X fprintf(FpOut, "\nWINDOWS\n"); X PrintType(FLG_MASK, FLG_WINDOW); X X fprintf(FpOut, "\nTABLES & SCREEN ARRAYS\n"); X PrintType(FLG_MASK, FLG_TBLSCR); X X fprintf(FpOut, "\nFIELDS\n"); X PrintType(FLG_MASK, FLG_FIELD); X} X Xint Xfglalpha(int c) X{ X return((c >= 'a' && c <= 'z') || X (c >= 'A' && c <= 'Z') || X (c == '_') || X (c >= '0' && c <= '9')); X} X X/* Be careful when setting the line-number ... cannot use the X * 'LineNo' when this routine ends, coz there may have been X * some additional processing after the token was found e.g. X * if a comment is parsed off. X */ Xint XParseFile(char *Strng) X{ X int c; X char *p = Strng; X X MultipleRefs = FALSE; X OutFileName = NULL; X FoundOn = 0; /* Not found yet */ X X while ((c = fgetc(fp)) != EOF) X { switch (c) X { case '{': X do X { c = fgetc(fp); X if (c == '\n') LineNo++; X } while (c != '}' && c != EOF); X continue; /* Continue while */ X case '"': X do X { c = fgetc(fp); X if (c == '\n') LineNo++; X } while (c != '"' && c != EOF); X continue; X case '\'': X do X { c = fgetc(fp); X if (c == '\n') LineNo++; X } while (c != '\'' && c != EOF); X continue; X case '-': X c = fgetc(fp); X if (c == '-') X { while ((c = fgetc(fp)) != '\n'); X LineNo++; X } X else X { ungetc(c, fp); X c = '-'; X } X break; X case '#': X while ((c = fgetc(fp)) != '\n'); X LineNo++; X continue; X default: X if (c == '\n') LineNo++; X break; X } X if (!fglalpha(c)) break; /* from while */ X *p++ = c; X if (!FoundOn) FoundOn = LineNo; X } X *p = 0; X return(c); X} X Xint Xnode_compare(char *node1, Node *node2) X{ X return strcasecmp(node1, node2->Name); X} X X/* Special processing if in the DEFINE section. X * Check to see if got a token that is still in this section. X */ Xvoid XCheckDefineEnd(char *Word, unsigned Flags, unsigned TokenId) X{ X if (TokenId == TOKEN_RECORD) return; X if (TokenId == TOKEN_LIKE) return; X X if (!(Flags & STAY_DEFINE)) X { Xfprintf(stderr, "Exit `InDefine' with `%s'\n", Word); X InDefine = FALSE; X } X} X Xvoid XUsage(char *ProgName) X{ X fprintf(stderr, "\nUsage: %s [-m] [-o output] filename\n", ProgName); X fprintf(stderr, "\t\t-m show repeated line numbers\n"); X fprintf(stderr, "\t\t-o output name of output file (default is stdout)\n"); X fprintf(stderr, "\t\tuse filename of '-' for stdin\n\n"); X exit(0); X} X Xvoid XParseCommandLine(int argc, char **argv) X{ X int i; X X fputs("\nInformix 4GL Cross-Reference v2.1 Released: 29 Dec 1992\n\n", stderr); X if (argc == 1) Usage(*argv); X X fp = NULL; /* Input file not yet determined */ X i = 1; X while (i < argc) X { if (argv[i][0] != '-') break; X switch (argv[i][1]) X { case '\0': X fp = stdin; X break; X case 'm': X MultipleRefs = TRUE; X break; X case 'o': X if (++i == argc) X { fprintf(stderr, "No output file specified with `-o'\n"); X Usage(argv[0]); X } X OutFileName = argv[i]; X break; X default: X fprintf(stderr, "Unrecognised option `%s'\n", argv[i]); X Usage(argv[0]); X break; X } X i++; X } X X if (fp == NULL) /* No stdin found */ X { if (i != argc - 1) Usage(argv[0]); /* Want *one* filename */ X if ((fp = fopen(argv[i], "r")) == NULL) X { fprintf(stderr, "Cannot open input file `%s'\n", argv[i]); X exit(-1); X } X } X X if (OutFileName) X if ((FpOut = fopen(OutFileName, "w")) == NULL) X { fprintf(stderr, "Cannot open output file `%s'\n", OutFileName); X exit(-1); X } X} X Xvoid XError(char *Msg) X{ X fprintf(stderr, "Error: Line %d: %s\n", FoundOn, Msg); X exit(-1); X} X X/* `LIKE' found. Parameter says whether to expect column-name X * as well. X */ Xvoid XProcessLike(BOOLEAN WithColumn) X{ X Entry *p; X DefnRec *q; X char Ch; X WordType Word; X X Ch = ParseFile(Word); X X p = GetHeader(Word); X q = GetActive(p, FLG_TABLE); X q->Flags = FLG_TABLE; X AddLineNum(q, FoundOn); X X if (WithColumn) X { Ch = ParseFile(Word); X X p = GetHeader(Word); X q = GetActive(p, FLG_FIELD); X q->Flags = FLG_FIELD; X AddLineNum(q, FoundOn); X } X} X X/* The last token was 'RECORD' X */ Xvoid XProcessRecord() X{ X Node *Ptr; X char Ch; X WordType Word; X X Ch = ParseFile(Word); X Ptr = (Node *)bsearch((void *)Word, word_table, WORD_TABSIZE, X sizeof(word_table[0]), node_compare); X if (Ptr) X { if (Ptr->TokenId == TOKEN_END) return; X if (Ptr->TokenId != TOKEN_LIKE) X Error("`LIKE' expected"); X ProcessLike(FALSE); X } X else /* Actual record defn follows */ X { X do X { X Ch = ParseFile(Word); X Ptr = (Node *)bsearch((void *)Word, X word_table, WORD_TABSIZE, X sizeof(word_table[0]), node_compare); X } while (!Ptr || Ptr->TokenId != TOKEN_RECORD); X X } X} X Xint Xmain(int argc, char **argv) X{ X Node *Ptr; X char Ch, Word[128]; X static char CharBefore = 0; X unsigned LastToken = 0; X unsigned Flags = 0; X BOOLEAN WantNext = TRUE, GotEnd, MaybeTbl; X X ParseCommandLine(argc, argv); X X LineNo = 1; X MaybeTbl = InGlobal = InParams = InFunction = GotEnd = InDefine = FALSE; X X for (;; CharBefore = Ch) X { Ch = ParseFile(Word); X if (Word[0] && !isdigit(Word[0]) && !(Word[0] == '.' && Word[1] == 0)) X { Ptr = (Node *)bsearch((void *)Word, X word_table, WORD_TABSIZE, X sizeof(word_table[0]), node_compare); X X if (Ptr) /* Check for special cases first */ X { if (Ptr->TokenId == TOKEN_END) X { GotEnd = TRUE; X Flags = 0; /* Nothing special about next token */ X continue; X } X X if (GotEnd) /* Last was an "end" */ X { switch(Ptr->TokenId) X { case TOKEN_FUNCTION: X case TOKEN_REPORT: X InFunction = InDefine = FALSE; X AllInactive(); /* Kill local scope */ X break; X case TOKEN_GLOBAL: X InGlobal = FALSE; X break; X } X GotEnd = FALSE; X Flags = 0; X continue; X } X X if (Ptr->TokenId == TOKEN_CONTROL || /* CONTROL-? */ X Ptr->TokenId == TOKEN_KEY) /* KEY xxx */ X { WantNext = FALSE; /* Ignore next token */ X Flags = 0; X continue; /* continue 'for' */ X } X } X X GotEnd = FALSE; /* No effect on valid 4GL! */ X X if (!WantNext) /* An unwanted token */ X { WantNext = TRUE; /* Yeah, take the following one! */ X continue; X } X X#ifdef DEBUG1 Xfprintf(stderr, "`%s' Reserved: %s\n", Word, Ptr ? "Yes" : "No"); Xfflush(stderr); X#endif X X if (Ptr == NULL) /* Not a "reserved" word */ X { if (MaybeTbl) X { Flags |= (Ch == '.' ? FLG_TABLE : FLG_FIELD); X if (LastToken != TOKEN_SELECT) MaybeTbl = FALSE; X } X else X { if (CharBefore == '.') Flags |= FLG_FIELD; /* Field in record */ X } X AddEntry(Word, Ch, FoundOn, Flags); X if (Flags == DEFN_FUNC) InParams = TRUE; /* Param after fn name */ X Flags = 0; X } X else /* Check for certain "reserved" words */ X { Flags = Ptr->Flags; /* Get flags for next token */ X if (InDefine) CheckDefineEnd(Word, Flags, Ptr->TokenId); X InParams = FALSE; /* If reserved word -> not parameter */ X MaybeTbl = FALSE; X switch (Ptr->TokenId) X { case TOKEN_DEFINE: X InDefine = TRUE; X break; X case TOKEN_FUNCTION: X case TOKEN_REPORT: X InFunction = TRUE; X break; X case TOKEN_GLOBAL: X InGlobal = TRUE; X break; X case TOKEN_LIKE: X if (InDefine) X { ProcessLike(TRUE); X Ch = 0; X } X else Error("Unexpected `LIKE'"); X break; X case TOKEN_RECORD: X if (InDefine) X { ProcessRecord(); X Ch = 0; X } X else Error("Unexpected `RECORD'"); X break; X case TOKEN_INTO: X if (LastToken == TOKEN_INSERT) Flags = FLG_TABLE; X break; X case TOKEN_WHERE: X case TOKEN_SELECT: X case TOKEN_SET: X MaybeTbl = TRUE; X break; X default: X break; X } X LastToken = Ptr->TokenId; X } X } X if (Ch == EOF) break; X } X X PrintList(); X X fclose(fp); X if (OutFileName) fclose(FpOut); X return(0); X} SHAR_EOF if [ `wc -c < dbxref.c` -ne 21368 ] then echo "Lengths do not match -- Bad Copy of dbxref.c" fi echo "Extracting file dbxref.h" sed -e 's/^X//' <<\SHAR_EOF > dbxref.h X/* keyword.h */ X/* This file was burgled from Dave Snyder's {"dbbeauty". X * Change made to the structure used. X */ X Xtypedef Xstruct _Node X { char *Name; X unsigned Flags; X unsigned TokenId; X } Node; X Xstatic Node word_table[] = { X {"abort", 0, 0}, X {"absolute", 0, 0}, X {"accept", 0, 0}, X {"access", 0, 0}, X {"add", 0, 0}, X {"after", 0, 0}, X {"all", 0, 0}, X {"allowing", 0, 0}, X {"alter", 0, 0}, X {"and", 0, 0}, X {"ansi", 0, 0}, X {"any", 0, 0}, X {"array", STAY_DEFINE, 0}, X {"as", 0, 0}, X {"asc", 0, 0}, X {"ascending", 0, 0}, X {"ascii", 0, 0}, X {"at", 0, 0}, X {"attribute", 0, 0}, X {"attributes", 0, 0}, X {"audit", 0, 0}, X {"auto", 0, 0}, X {"autonext", 0, 0}, X {"average", 0, 0}, X {"avg", 0, 0}, X {"backround", 0, 0}, X {"before", 0, 0}, X {"begin", 0, 0}, X {"beginning", 0, 0}, X {"bell", 0, 0}, X {"between", 0, 0}, X {"black", 0, 0}, X {"blanks", 0, 0}, X {"blink", 0, 0}, X {"blue", 0, 0}, X {"bold", 0, 0}, X {"border", 0, 0}, X {"bottom", 0, 0}, X {"break", 0, 0}, X {"buffered", 0, 0}, X {"by", 0, 0}, X {"byte", STAY_DEFINE, 0}, X {"call", FLG_FUNC, 0}, X {"case", 0, 0}, X {"char", STAY_DEFINE, 0}, X {"character", STAY_DEFINE, 0}, X {"check", 0, 0}, X {"clear", 0, 0}, X {"clipped", 0, 0}, X {"close", 0, 0}, X {"cluster", 0, 0}, X {"col", 0, 0}, X {"color", 0, 0}, X {"colors", 0, 0}, X {"column", 0, 0}, X {"columns", 0, 0}, X {"command", 0, 0}, X {"comment", 0, 0}, X {"comments", 0, 0}, X {"commit", 0, 0}, X {"committed", 0, 0}, X {"composites", 0, 0}, X {"compress", 0, 0}, X {"connect", 0, 0}, X {"constant", 0, 0}, X {"constraint", 0, 0}, X {"construct", 0, 0}, X {"continue", 0, 0}, X {"control", 0, TOKEN_CONTROL}, X {"convert", 0, 0}, X {"count", 0, 0}, X {"create", 0, 0}, X {"current", 0, 0}, X {"cursor", 0, 0}, X {"cyan", 0, 0}, X {"database", 0, 0}, X {"date", STAY_DEFINE, 0}, X {"date_type", 0, 0}, X {"datetime", STAY_DEFINE, 0}, X {"day", 0, 0}, X {"dba", 0, 0}, X {"debug", 0, 0}, X {"dec", STAY_DEFINE, 0}, X {"dec_t", 0, 0}, X {"decimal", STAY_DEFINE, 0}, X {"decimal_type", 0, 0}, X {"declare", FLG_CURSOR, 0}, X {"default", 0, 0}, X {"defaults", 0, 0}, X {"defer", 0, 0}, X {"define", 0, TOKEN_DEFINE}, X {"delete", 0, 0}, X {"delimiter", 0, 0}, X {"delimiters", 0, 0}, X {"desc", 0, 0}, X {"descending", 0, 0}, X {"describe", 0, 0}, X {"descriptor", 0, 0}, X {"dim", 0, 0}, X {"dirty", 0, 0}, X {"display", 0, 0}, X {"displayonly", 0, 0}, X {"distinct", 0, 0}, X {"do", 0, 0}, X {"dominant", 0, 0}, X {"double", STAY_DEFINE, 0}, X {"down", 0, 0}, X {"downshift", 0, 0}, X {"drop", 0, 0}, X {"dtime", 0, 0}, X {"dtime_t", 0, 0}, X {"editadd", 0, 0}, X {"editupdate", 0, 0}, X {"else", 0, 0}, X {"end", STAY_DEFINE, TOKEN_END}, X {"end-exec", 0, 0}, X {"endif", 0, 0}, X {"ending", 0, 0}, X {"enum", 0, 0}, X {"error", 0, 0}, X {"escape", 0, 0}, X {"every", 0, 0}, X {"exclusive", 0, 0}, X {"exec", 0, 0}, X {"execute", 0, 0}, X {"exists", 0, 0}, X {"exit", 0, 0}, X {"exitnow", 0, 0}, X {"exits", 0, 0}, X {"explain", 0, 0}, X {"extend", 0, 0}, X {"extent", 0, 0}, X {"extern", 0, 0}, X {"external", 0, 0}, X {"false", 0, 0}, X {"fetch", 0, 0}, X {"field", 0, 0}, X {"file", 0, 0}, X {"finish", 0, 0}, X {"first", 0, 0}, X {"fixchar", 0, 0}, X {"float", STAY_DEFINE, 0}, X {"flush", 0, 0}, X {"for", 0, 0}, X {"foreach", FLG_CURSOR, 0}, X {"form", 0, 0}, X {"format", 0, 0}, X {"formonly", 0, 0}, X {"found", 0, 0}, X {"fraction", 0, 0}, X {"free", 0, 0}, X {"from", FLG_TBLSCR, 0}, X {"function", DEFN_FUNC, TOKEN_FUNCTION}, X {"globals", 0, TOKEN_GLOBAL}, X {"go", 0, 0}, X {"goto", FLG_LABEL, 0}, X {"grant", 0, 0}, X {"green", 0, 0}, X {"group", 0, 0}, X {"having", 0, 0}, X {"header", 0, 0}, X {"headings", 0, 0}, X {"help", 0, 0}, X {"hold", 0, 0}, X {"hour", 0, 0}, X {"identified", 0, 0}, X {"if", 0, 0}, X {"ifdef", 0, 0}, X {"ifndef", 0, 0}, X {"immediate", 0, 0}, X {"in", 0, 0}, X {"include", 0, 0}, X {"index", 0, 0}, X {"indicator", 0, 0}, X {"infield", 0, 0}, X {"info", 0, 0}, X {"initialize", 0, 0}, X {"input", 0, 0}, X {"insert", 0, TOKEN_INSERT}, X {"instructions", 0, 0}, X {"int", 0, 0}, X {"integer", STAY_DEFINE, 0}, X {"interrupt", 0, 0}, X {"intersect", 0, 0}, X {"interval", STAY_DEFINE, 0}, X {"into", 0, TOKEN_INTO}, X {"intrvl_t", 0, 0}, X {"inverse", 0, 0}, X {"invisible", 0, 0}, X {"is", 0, 0}, X {"isam", 0, 0}, X {"isolation", 0, 0}, X {"join", 0, 0}, X {"joining", 0, 0}, X {"key", 0, TOKEN_KEY}, X {"label", DEFN_LABEL, 0}, X {"last", 0, 0}, X {"left", 0, 0}, X {"len", 0, 0}, X {"length", 0, 0}, X {"let", 0, 0}, X {"like", STAY_DEFINE, TOKEN_LIKE}, X {"line", 0, 0}, X {"lineno", 0, 0}, X {"lines", 0, 0}, X {"load", 0, 0}, X {"loc_t", 0, 0}, X {"locator", 0, 0}, X {"lock", 0, 0}, X {"log", 0, 0}, X {"long", 0, 0}, X {"long_float", 0, 0}, X {"long_integer", 0, 0}, X {"lookup", 0, 0}, X {"loop", 0, 0}, X {"magenta", 0, 0}, X {"main", 0, 0}, X {"margin", 0, 0}, X {"master", 0, 0}, X {"matches", 0, 0}, X {"max", 0, 0}, X {"mdy", 0, 0}, X {"memory", 0, 0}, X {"menu", 0, 0}, X {"message", 0, 0}, X {"min", 0, 0}, X {"minus", 0, 0}, X {"minute", 0, 0}, X {"mod", 0, 0}, X {"mode", 0, 0}, X {"modify", 0, 0}, X {"module", 0, 0}, X {"money", STAY_DEFINE, 0}, X {"month", 0, 0}, X {"name", 0, 0}, X {"natural", 0, 0}, X {"need", 0, 0}, X {"new", 0, 0}, X {"next", 0, 0}, X {"nextfield", 0, 0}, X {"no", 0, 0}, X {"nocr", 0, 0}, X {"noentry", 0, 0}, X {"normal", 0, 0}, X {"not", 0, 0}, X {"notfound", 0, 0}, X {"noupdate", 0, 0}, X {"now", 0, 0}, X {"null", 0, 0}, X {"numeric", STAY_DEFINE, 0}, X {"of", STAY_DEFINE, 0}, X {"off", 0, 0}, X {"on", 0, 0}, X {"open", 0, 0}, X {"option", 0, 0}, X {"options", 0, 0}, X {"or", 0, 0}, X {"order", 0, 0}, X {"otherwise", 0, 0}, X {"out", 0, 0}, X {"outer", 0, 0}, X {"output", 0, 0}, X {"package", 0, 0}, X {"page", 0, 0}, X {"pageno", 0, 0}, X {"param", 0, 0}, X {"pause", 0, 0}, X {"percent", 0, 0}, X {"perform", 0, 0}, X {"picture", 0, 0}, X {"pipe", 0, 0}, X {"positive", 0, 0}, X {"precision", STAY_DEFINE, 0}, X {"prepare", 0, 0}, X {"previous", 0, 0}, X {"print", 0, 0}, X {"printer", 0, 0}, X {"prior", 0, 0}, X {"privilege", 0, 0}, X {"privileges", 0, 0}, X {"program", 0, 0}, X {"prompt", 0, 0}, X {"public", 0, 0}, X {"put", 0, 0}, X {"query", 0, 0}, X {"queryclear", 0, 0}, X {"quit", 0, 0}, X {"raise", 0, 0}, X {"range", 0, 0}, X {"read", 0, 0}, X {"readonly", 0, 0}, X {"real", STAY_DEFINE, 0}, X {"record", STAY_DEFINE, TOKEN_RECORD}, X {"recover", 0, 0}, X {"red", 0, 0}, X {"register", 0, 0}, X {"relative", 0, 0}, X {"remove", 0, 0}, X {"rename", 0, 0}, X {"repair", 0, 0}, X {"repeatable", 0, 0}, X {"report", FLG_REPORT, TOKEN_REPORT}, X {"required", 0, 0}, X {"resource", 0, 0}, X {"return", 0, 0}, X {"returning", 0, 0}, X {"reverse", 0, 0}, X {"revoke", 0, 0}, X {"rforward", 0, 0}, X {"right", 0, 0}, X {"rollback", 0, 0}, X {"rollforward", 0, 0}, X {"row", 0, 0}, X {"rowid", 0, 0}, X {"rows", 0, 0}, X {"run", 0, 0}, X {"savepoint", 0, 0}, X {"screen", 0, 0}, X {"scroll", 0, 0}, X {"second", 0, 0}, X {"section", 0, 0}, X {"select", 0, TOKEN_SELECT}, X {"serial", STAY_DEFINE, 0}, X {"serial_type", 0, 0}, X {"set", 0, TOKEN_SET}, X {"share", 0, 0}, X {"shift", 0, 0}, X {"short", 0, 0}, X {"short_float", 0, 0}, X {"short_integer", 0, 0}, X {"sitename", 0, 0}, X {"size", 0, 0}, X {"sizeof", 0, 0}, X {"skip", 0, 0}, X {"sleep", 0, 0}, X {"smallfloat", STAY_DEFINE, 0}, X {"smallint", STAY_DEFINE, 0}, X {"smfloat", 0, 0}, X {"smint", 0, 0}, X {"some", 0, 0}, X {"space", 0, 0}, X {"spaces", 0, 0}, X {"sql", 0, 0}, X {"sqlca", 0, 0}, X {"sqlchar_type", 0, 0}, X {"sqlda", 0, 0}, X {"sqldecimal_type", 0, 0}, X {"sqlerr", 0, 0}, X {"sqlerror", 0, 0}, X {"sqlfloat_type", 0, 0}, X {"sqlint_type", 0, 0}, X {"sqlmoney_type", 0, 0}, X {"sqlsmfloat_type", 0, 0}, X {"sqlsmint_type", 0, 0}, X {"sqlwarning", 0, 0}, X {"stability", 0, 0}, X {"start", 0, 0}, X {"startlog", 0, 0}, X {"static", 0, 0}, X {"statistics", 0, 0}, X {"status", 0, 0}, X {"stdv", 0, 0}, X {"step", 0, 0}, X {"stop", 0, 0}, X {"string", 0, 0}, X {"struct", 0, 0}, X {"substract", 0, 0}, X {"subtype", 0, 0}, X {"sum", 0, 0}, X {"switch", 0, 0}, X {"synonym", 0, 0}, X {"systables", 0, 0}, X {"table", FLG_TABLE, 0}, X {"tables", 0, 0}, X {"temp", 0, 0}, X {"text", STAY_DEFINE, 0}, X {"then", 0, 0}, X {"through", 0, 0}, X {"thru", 0, 0}, X {"time", 0, 0}, X {"tiny_integer", 0, 0}, X {"to", 0, 0}, X {"today", 0, 0}, X {"top", 0, 0}, X {"total", 0, 0}, X {"trailer", 0, 0}, X {"trailing", 0, 0}, X {"true", 0, 0}, X {"type", 0, 0}, X {"typedef", 0, 0}, X {"undef", 0, 0}, X {"underline", 0, 0}, X {"union", 0, 0}, X {"unique", 0, 0}, X {"units", 0, 0}, X {"unload", 0, 0}, X {"unlock", 0, 0}, X {"unsigned", 0, 0}, X {"up", 0, 0}, X {"update", FLG_TABLE, 0}, X {"upshift", 0, 0}, X {"user", 0, 0}, X {"using", 0, 0}, X {"validate", 0, 0}, X {"values", 0, 0}, X {"varchar", STAY_DEFINE, 0}, X {"variable", 0, 0}, X {"vc_t", 0, 0}, X {"verify", 0, 0}, X {"view", 0, 0}, X {"void", 0, 0}, X {"wait", 0, 0}, X {"waiting", 0, 0}, X {"warning", 0, 0}, X {"wcolor", 0, 0}, X {"weekday", 0, 0}, X {"when", 0, 0}, X {"whenever", 0, 0}, X {"where", 0, TOKEN_WHERE}, X {"while", 0, 0}, X {"white", 0, 0}, X {"window", FLG_WINDOW, 0}, X {"with", 0, 0}, X {"without", 0, 0}, X {"wordwrap", 0, 0}, X {"work", 0, 0}, X {"wrap", 0, 0}, X {"year", 0, 0}, X {"yellow", 0, 0}, X {"yes", 0, 0}, X {"zerofill", 0, 0} X}; X X#define WORD_TABSIZE (sizeof(word_table) / sizeof(word_table[0])) SHAR_EOF if [ `wc -c < dbxref.h` -ne 8989 ] then echo "Lengths do not match -- Bad Copy of dbxref.h" fi echo "Done."