mirror of
git://git.code.sf.net/p/cdesktopenv/code
synced 2025-03-09 15:50:02 +00:00
merge, mkcatdefs: add missing includes, clean up trailing whitespace
This commit is contained in:
parent
0a62def9bd
commit
0aec3c159f
2 changed files with 82 additions and 80 deletions
|
@ -95,6 +95,7 @@
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <locale.h>
|
#include <locale.h>
|
||||||
|
#include <unistd.h>
|
||||||
#include <nl_types.h>
|
#include <nl_types.h>
|
||||||
|
|
||||||
nl_catd catfile[2] = {NULL, NULL}; /* [0] for primary, [1] for default */
|
nl_catd catfile[2] = {NULL, NULL}; /* [0] for primary, [1] for default */
|
||||||
|
|
|
@ -46,6 +46,7 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <locale.h>
|
#include <locale.h>
|
||||||
|
#include <unistd.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
|
||||||
|
@ -110,7 +111,7 @@ static int hash(char *);
|
||||||
* mkcatdefs <name> <msg_file>
|
* mkcatdefs <name> <msg_file>
|
||||||
*
|
*
|
||||||
* Results are 1) Creates header file <name>.h.
|
* Results are 1) Creates header file <name>.h.
|
||||||
* 2) Displays message file to stdout. The message file is
|
* 2) Displays message file to stdout. The message file is
|
||||||
* ready to be used as input to gencat.
|
* ready to be used as input to gencat.
|
||||||
*
|
*
|
||||||
* mkcatdefs takes a message definition file and produces
|
* mkcatdefs takes a message definition file and produces
|
||||||
|
@ -126,28 +127,28 @@ static int hash(char *);
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int
|
int
|
||||||
main (int argc,
|
main (int argc,
|
||||||
char *argv[])
|
char *argv[])
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
char *cp;
|
char *cp;
|
||||||
int count;
|
int count;
|
||||||
char *t;
|
char *t;
|
||||||
|
|
||||||
setlocale (LC_ALL,"");
|
setlocale (LC_ALL,"");
|
||||||
|
|
||||||
/* usage: handle multiple files; -h option has to be at the end */
|
/* usage: handle multiple files; -h option has to be at the end */
|
||||||
if (argc < 3) {
|
if (argc < 3) {
|
||||||
fprintf (stderr,
|
fprintf (stderr,
|
||||||
"mkcatdefs: Usage: %s header_file msg_file [msg_file...] [-h]\n",
|
"mkcatdefs: Usage: %s header_file msg_file [msg_file...] [-h]\n",
|
||||||
argv [0]);
|
argv [0]);
|
||||||
exit (0);
|
exit (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* check if include file should be created; -h is the last argument */
|
/* check if include file should be created; -h is the last argument */
|
||||||
if (argv[argc-1][0] == '-' && argv[argc-1][1] == 'h')
|
if (argv[argc-1][0] == '-' && argv[argc-1][1] == 'h')
|
||||||
inclfile = 0;
|
inclfile = 0;
|
||||||
|
|
||||||
/* open header output file */
|
/* open header output file */
|
||||||
if (inclfile) {
|
if (inclfile) {
|
||||||
mname = argv [1];
|
mname = argv [1];
|
||||||
|
@ -178,14 +179,14 @@ main (int argc,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else sprintf (outname, "msg.h");
|
} else sprintf (outname, "msg.h");
|
||||||
|
|
||||||
|
|
||||||
/* open new msg output file */
|
/* open new msg output file */
|
||||||
msgfp = stdout;
|
msgfp = stdout;
|
||||||
|
|
||||||
/* if message descriptor files were specified then process each one in turn
|
/* if message descriptor files were specified then process each one in turn
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (inclfile == 0 )
|
if (inclfile == 0 )
|
||||||
count = argc - 1;
|
count = argc - 1;
|
||||||
else
|
else
|
||||||
|
@ -208,17 +209,17 @@ main (int argc,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (inclfile) {
|
if (inclfile) {
|
||||||
fflush (outfp);
|
fflush (outfp);
|
||||||
if (ferror (outfp)) {
|
if (ferror (outfp)) {
|
||||||
fprintf (stderr, "mkcatdefs: There were write errors on file %s\n",
|
fprintf (stderr, "mkcatdefs: There were write errors on file %s\n",
|
||||||
outname);
|
outname);
|
||||||
errflg = 1;
|
errflg = 1;
|
||||||
}
|
}
|
||||||
fclose (outfp);
|
fclose (outfp);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (errflg) {
|
if (errflg) {
|
||||||
fprintf (stderr, "mkcatdefs: Errors found: no %s created\n", outname);
|
fprintf (stderr, "mkcatdefs: Errors found: no %s created\n", outname);
|
||||||
if (inclfile) unlink(outname);
|
if (inclfile) unlink(outname);
|
||||||
|
@ -231,8 +232,8 @@ main (int argc,
|
||||||
outname);
|
outname);
|
||||||
unlink (outname);
|
unlink (outname);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
fprintf(stderr, "mkcatdefs: no %s created\n", outname);
|
fprintf(stderr, "mkcatdefs: no %s created\n", outname);
|
||||||
}
|
}
|
||||||
exit (errflg);
|
exit (errflg);
|
||||||
|
@ -260,16 +261,16 @@ mkcatdefs(char *fname)
|
||||||
int n;
|
int n;
|
||||||
int contin = 0;
|
int contin = 0;
|
||||||
int len; /* # bytes in a character */
|
int len; /* # bytes in a character */
|
||||||
|
|
||||||
|
|
||||||
/* put out header for include file */
|
/* put out header for include file */
|
||||||
if (inclfile)
|
if (inclfile)
|
||||||
{
|
{
|
||||||
fprintf (outfp, "/* $%s$ */\n", "XConsortium");
|
fprintf (outfp, "/* $%s$ */\n", "XConsortium");
|
||||||
fprintf (outfp, "\n\n/* The following was generated from %s. */\n\n",
|
fprintf (outfp, "\n\n/* The following was generated from %s. */\n\n",
|
||||||
fname);
|
fname);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* process the message file */
|
/* process the message file */
|
||||||
while (fgets(line, MAXLINELEN, descfile)) {
|
while (fgets(line, MAXLINELEN, descfile)) {
|
||||||
line[MAXLINELEN-1] = '\0'; /* terminate in case length exceeded */
|
line[MAXLINELEN-1] = '\0'; /* terminate in case length exceeded */
|
||||||
|
@ -277,8 +278,8 @@ mkcatdefs(char *fname)
|
||||||
for (cp=line; *cp; cp+=len) {
|
for (cp=line; *cp; cp+=len) {
|
||||||
len = mblen(cp, MB_CUR_MAX);
|
len = mblen(cp, MB_CUR_MAX);
|
||||||
if (len < 0) {
|
if (len < 0) {
|
||||||
fprintf (stderr,
|
fprintf (stderr,
|
||||||
"mkcatdefs: sourcefile contains invalid character:\n\t%s",
|
"mkcatdefs: sourcefile contains invalid character:\n\t%s",
|
||||||
line);
|
line);
|
||||||
errflg = 1;
|
errflg = 1;
|
||||||
return;
|
return;
|
||||||
|
@ -291,7 +292,7 @@ mkcatdefs(char *fname)
|
||||||
for (cpt = cp; *cp; cp += len) {
|
for (cpt = cp; *cp; cp += len) {
|
||||||
len = mblen(cp, MB_CUR_MAX);
|
len = mblen(cp, MB_CUR_MAX);
|
||||||
if (len < 0) {
|
if (len < 0) {
|
||||||
fprintf (stderr,
|
fprintf (stderr,
|
||||||
"mkcatdefs: sourcefile contains invalid character:\n\t%s",
|
"mkcatdefs: sourcefile contains invalid character:\n\t%s",
|
||||||
line);
|
line);
|
||||||
errflg = 1;
|
errflg = 1;
|
||||||
|
@ -310,19 +311,19 @@ mkcatdefs(char *fname)
|
||||||
fputs (line, msgfp);
|
fputs (line, msgfp);
|
||||||
continue; /* line is a comment */
|
continue; /* line is a comment */
|
||||||
}
|
}
|
||||||
if ((strncmp (cp, "set", 3) == 0) &&
|
if ((strncmp (cp, "set", 3) == 0) &&
|
||||||
((len = mblen(&(cp[3]), MB_CUR_MAX)) == 1) &&
|
((len = mblen(&(cp[3]), MB_CUR_MAX)) == 1) &&
|
||||||
(isspace(cp[3]) != 0)) {
|
(isspace(cp[3]) != 0)) {
|
||||||
char setname [MAXIDLEN];
|
char setname [MAXIDLEN];
|
||||||
|
|
||||||
sscanf (cp+3+len, "%s", setname);
|
sscanf (cp+3+len, "%s", setname);
|
||||||
if (inclfile)
|
if (inclfile)
|
||||||
fprintf (outfp, "\n/* definitions for set %s */\n", setname, "");
|
fprintf (outfp, "\n/* definitions for set %s */\n", setname);
|
||||||
if (isdigit(setname[0])) {
|
if (isdigit(setname[0])) {
|
||||||
cpt = setname;
|
cpt = setname;
|
||||||
do {
|
do {
|
||||||
if (!isdigit(*cpt)) {
|
if (!isdigit(*cpt)) {
|
||||||
fprintf(stderr, "mkcatdefs: %s is an invalid identifier\n",
|
fprintf(stderr, "mkcatdefs: %s is an invalid identifier\n",
|
||||||
setname);
|
setname);
|
||||||
errflg = 1;
|
errflg = 1;
|
||||||
return;
|
return;
|
||||||
|
@ -333,11 +334,11 @@ mkcatdefs(char *fname)
|
||||||
setno = n;
|
setno = n;
|
||||||
else {
|
else {
|
||||||
if (n == 0)
|
if (n == 0)
|
||||||
fprintf(stderr, "mkcatdefs: %s is an invalid identifier\n",
|
fprintf(stderr, "mkcatdefs: %s is an invalid identifier\n",
|
||||||
setname);
|
setname);
|
||||||
else
|
else
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"mkcatdefs: set # %d already assigned or sets not in ascending sequence\n",
|
"mkcatdefs: set # %d already assigned or sets not in ascending sequence\n",
|
||||||
n);
|
n);
|
||||||
errflg = 1;
|
errflg = 1;
|
||||||
return;
|
return;
|
||||||
|
@ -347,15 +348,15 @@ mkcatdefs(char *fname)
|
||||||
do {
|
do {
|
||||||
len = mblen(cpt, MB_CUR_MAX);
|
len = mblen(cpt, MB_CUR_MAX);
|
||||||
if (len <= 0) {
|
if (len <= 0) {
|
||||||
fprintf (stderr,
|
fprintf (stderr,
|
||||||
"mkcatdefs: sourcefile contains invalid character:\n\t%s",
|
"mkcatdefs: sourcefile contains invalid character:\n\t%s",
|
||||||
line);
|
line);
|
||||||
errflg = 1;
|
errflg = 1;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (len == 1 && (isalnum(*cpt) == 0) && (*cpt != '_')) {
|
if (len == 1 && (isalnum(*cpt) == 0) && (*cpt != '_')) {
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"mkcatdefs: %s is an invalid identifier\n",
|
"mkcatdefs: %s is an invalid identifier\n",
|
||||||
setname);
|
setname);
|
||||||
errflg = 1;
|
errflg = 1;
|
||||||
return;
|
return;
|
||||||
|
@ -382,12 +383,12 @@ mkcatdefs(char *fname)
|
||||||
contin = 0;
|
contin = 0;
|
||||||
} else if (setno > 1) { /* set must have been seen first */
|
} else if (setno > 1) { /* set must have been seen first */
|
||||||
char msgname [MAXIDLEN];
|
char msgname [MAXIDLEN];
|
||||||
|
|
||||||
msgname [0] = '\0';
|
msgname [0] = '\0';
|
||||||
if (sscanf (cp, "%s", msgname) && msgname[0]) {
|
if (sscanf (cp, "%s", msgname) && msgname[0]) {
|
||||||
len = mblen(cp, MB_CUR_MAX);
|
len = mblen(cp, MB_CUR_MAX);
|
||||||
if (len < 0) {
|
if (len < 0) {
|
||||||
fprintf (stderr,
|
fprintf (stderr,
|
||||||
"mkcatdefs: sourcefile contains invalid character:\n\t%s",
|
"mkcatdefs: sourcefile contains invalid character:\n\t%s",
|
||||||
line);
|
line);
|
||||||
errflg = 1;
|
errflg = 1;
|
||||||
|
@ -398,15 +399,15 @@ mkcatdefs(char *fname)
|
||||||
do {
|
do {
|
||||||
len = mblen(cpt, MB_CUR_MAX);
|
len = mblen(cpt, MB_CUR_MAX);
|
||||||
if (len < 0) {
|
if (len < 0) {
|
||||||
fprintf (stderr,
|
fprintf (stderr,
|
||||||
"mkcatdefs: sourcefile contains invalid character:\n\t%s",
|
"mkcatdefs: sourcefile contains invalid character:\n\t%s",
|
||||||
line);
|
line);
|
||||||
errflg = 1;
|
errflg = 1;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (len == 1 && (isalnum(*cpt) == 0) && (*cpt != '_')) {
|
if (len == 1 && (isalnum(*cpt) == 0) && (*cpt != '_')) {
|
||||||
fprintf(stderr, "mkcatdefs: %s is an invalid identifier\n",
|
fprintf(stderr, "mkcatdefs: %s is an invalid identifier\n",
|
||||||
msgname);
|
msgname);
|
||||||
errflg = 1;
|
errflg = 1;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -419,8 +420,8 @@ mkcatdefs(char *fname)
|
||||||
if (chkcontin(line))
|
if (chkcontin(line))
|
||||||
contin = 1;
|
contin = 1;
|
||||||
if(insert(msgname,msgno++) < 0) {
|
if(insert(msgname,msgno++) < 0) {
|
||||||
fprintf(stderr, "mkcatdefs: name %s used more than once\n",
|
fprintf(stderr, "mkcatdefs: name %s used more than once\n",
|
||||||
msgname);
|
msgname);
|
||||||
errflg = 1;
|
errflg = 1;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -440,11 +441,11 @@ mkcatdefs(char *fname)
|
||||||
else {
|
else {
|
||||||
errflg = 1;
|
errflg = 1;
|
||||||
if (n == 0)
|
if (n == 0)
|
||||||
fprintf(stderr, "mkcatdefs: %d is an invalid identifier\n",
|
fprintf(stderr, "mkcatdefs: %d is an invalid identifier\n",
|
||||||
msgno);
|
msgno);
|
||||||
else if (n == msgno)
|
else if (n == msgno)
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"mkcatdefs: message id %s already assigned to identifier\n",
|
"mkcatdefs: message id %s already assigned to identifier\n",
|
||||||
msgname);
|
msgname);
|
||||||
else
|
else
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
|
@ -458,7 +459,7 @@ mkcatdefs(char *fname)
|
||||||
}
|
}
|
||||||
fputs (line, msgfp);
|
fputs (line, msgfp);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* make sure the operations read/write operations were successful */
|
/* make sure the operations read/write operations were successful */
|
||||||
if (ferror(descfile)) {
|
if (ferror(descfile)) {
|
||||||
fprintf (stderr, "mkcatdefs: There were read errors on file %s\n", inname);
|
fprintf (stderr, "mkcatdefs: There were read errors on file %s\n", inname);
|
||||||
|
@ -479,17 +480,17 @@ mkcatdefs(char *fname)
|
||||||
* 1 - continuation line.
|
* 1 - continuation line.
|
||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
chkcontin(char *line)
|
chkcontin(char *line)
|
||||||
{
|
{
|
||||||
int len; /* # bytes in character */
|
int len; /* # bytes in character */
|
||||||
wchar_t wc; /* process code of current character in line */
|
wchar_t wc; /* process code of current character in line */
|
||||||
wchar_t wcprev; /* process code of previous character in line */
|
wchar_t wcprev; /* process code of previous character in line */
|
||||||
|
|
||||||
for (wc=0; *line; line+=len) {
|
for (wc=0; *line; line+=len) {
|
||||||
wcprev = wc;
|
wcprev = wc;
|
||||||
len = mbtowc(&wc, line, MB_CUR_MAX);
|
len = mbtowc(&wc, line, MB_CUR_MAX);
|
||||||
if (len < 0) {
|
if (len < 0) {
|
||||||
fprintf (stderr,
|
fprintf (stderr,
|
||||||
"mkcatdefs: sourcefile contains invalid character:\n\t%s",
|
"mkcatdefs: sourcefile contains invalid character:\n\t%s",
|
||||||
line);
|
line);
|
||||||
errflg = 1;
|
errflg = 1;
|
||||||
|
@ -518,9 +519,9 @@ static struct name *symtab[HASHSIZE]; /* hashed pointers to binary trees */
|
||||||
*
|
*
|
||||||
* FUNCTION: Insert symbol
|
* FUNCTION: Insert symbol
|
||||||
*
|
*
|
||||||
* EXECUTION ENVIRONMENT:
|
* EXECUTION ENVIRONMENT:
|
||||||
* User mode.
|
* User mode.
|
||||||
*
|
*
|
||||||
* NOTES: These routines manipulate a symbol table for the mkcatdefs program.
|
* NOTES: These routines manipulate a symbol table for the mkcatdefs program.
|
||||||
* The symbol table is organized as a hashed set of binary trees. If the
|
* The symbol table is organized as a hashed set of binary trees. If the
|
||||||
* symbol being passed in is found then a -1 is returned, otherwise the
|
* symbol being passed in is found then a -1 is returned, otherwise the
|
||||||
|
@ -533,49 +534,49 @@ static struct name *symtab[HASHSIZE]; /* hashed pointers to binary trees */
|
||||||
* -1 - symbol exists.
|
* -1 - symbol exists.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static int
|
static int
|
||||||
insert(char *tname,
|
insert(char *tname,
|
||||||
int seqno)
|
int seqno)
|
||||||
/*
|
/*
|
||||||
tname - pointer to symbol
|
tname - pointer to symbol
|
||||||
seqno - integer value of symbol
|
seqno - integer value of symbol
|
||||||
*/
|
*/
|
||||||
|
|
||||||
{
|
{
|
||||||
struct name *ptr,*optr;
|
struct name *ptr,*optr;
|
||||||
int rslt = -1,i,hashval;
|
int rslt = -1,i,hashval;
|
||||||
|
|
||||||
hashval = hash(tname);
|
hashval = hash(tname);
|
||||||
ptr = symtab[hashval];
|
ptr = symtab[hashval];
|
||||||
|
|
||||||
/* search the binary tree for specified symbol */
|
/* search the binary tree for specified symbol */
|
||||||
while (ptr && (rslt = strcmp(tname,ptr->regname))) {
|
while (ptr && (rslt = strcmp(tname,ptr->regname))) {
|
||||||
optr=ptr;
|
optr=ptr;
|
||||||
if (rslt<0)
|
if (rslt<0)
|
||||||
ptr = ptr->left;
|
ptr = ptr->left;
|
||||||
else
|
else
|
||||||
ptr = ptr->right;
|
ptr = ptr->right;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rslt == 0) /* found the symbol already defined */
|
if (rslt == 0) /* found the symbol already defined */
|
||||||
return (-1);
|
return (-1);
|
||||||
else { /* symbol not defined yet so put it into symbol table */
|
else { /* symbol not defined yet so put it into symbol table */
|
||||||
ptr = (struct name *)calloc(sizeof(struct name), 1);
|
ptr = (struct name *)calloc(sizeof(struct name), 1);
|
||||||
ptr->regname = malloc(strlen(tname) + 1);
|
ptr->regname = malloc(strlen(tname) + 1);
|
||||||
strcpy (ptr->regname, tname);
|
strcpy (ptr->regname, tname);
|
||||||
ptr->regnr = seqno;
|
ptr->regnr = seqno;
|
||||||
|
|
||||||
/* not first entry in tree so update branch pointer */
|
/* not first entry in tree so update branch pointer */
|
||||||
if (symtab[hashval]) {
|
if (symtab[hashval]) {
|
||||||
if (rslt < 0)
|
if (rslt < 0)
|
||||||
optr->left = ptr;
|
optr->left = ptr;
|
||||||
else
|
else
|
||||||
optr->right = ptr;
|
optr->right = ptr;
|
||||||
|
|
||||||
/* first entry in tree so set the root pointer */
|
/* first entry in tree so set the root pointer */
|
||||||
} else
|
} else
|
||||||
symtab[hashval] = ptr;
|
symtab[hashval] = ptr;
|
||||||
|
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -585,37 +586,37 @@ insert(char *tname,
|
||||||
*
|
*
|
||||||
* FUNCTION: Search for symbol
|
* FUNCTION: Search for symbol
|
||||||
*
|
*
|
||||||
* EXECUTION ENVIRONMENT:
|
* EXECUTION ENVIRONMENT:
|
||||||
* User mode.
|
* User mode.
|
||||||
*
|
*
|
||||||
* NOTES: Searches for specific identifier. If found, return allocated number.
|
* NOTES: Searches for specific identifier. If found, return allocated number.
|
||||||
* If not found, return -1.
|
* If not found, return -1.
|
||||||
*
|
*
|
||||||
* RETURNS: Symbol sequence number if symbol is found.
|
* RETURNS: Symbol sequence number if symbol is found.
|
||||||
* -1 if symbol is not found.
|
* -1 if symbol is not found.
|
||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
nsearch (char *tname)
|
nsearch (char *tname)
|
||||||
/*
|
/*
|
||||||
tname - pointer to symbol
|
tname - pointer to symbol
|
||||||
*/
|
*/
|
||||||
|
|
||||||
{
|
{
|
||||||
struct name *ptr,*optr;
|
struct name *ptr,*optr;
|
||||||
int rslt = -1,i,hashval;
|
int rslt = -1,i,hashval;
|
||||||
|
|
||||||
hashval = hash(tname);
|
hashval = hash(tname);
|
||||||
ptr = symtab[hashval];
|
ptr = symtab[hashval];
|
||||||
|
|
||||||
/* search the binary tree for specified symbol */
|
/* search the binary tree for specified symbol */
|
||||||
while (ptr && (rslt = strcmp(tname,ptr->regname))) {
|
while (ptr && (rslt = strcmp(tname,ptr->regname))) {
|
||||||
optr=ptr;
|
optr=ptr;
|
||||||
if (rslt<0)
|
if (rslt<0)
|
||||||
ptr = ptr->left;
|
ptr = ptr->left;
|
||||||
else
|
else
|
||||||
ptr = ptr->right;
|
ptr = ptr->right;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rslt == 0) /* found the symbol already defined */
|
if (rslt == 0) /* found the symbol already defined */
|
||||||
return(ptr->regnr);
|
return(ptr->regnr);
|
||||||
else
|
else
|
||||||
|
@ -628,22 +629,22 @@ nsearch (char *tname)
|
||||||
*
|
*
|
||||||
* FUNCTION: Create hash value from symbol name.
|
* FUNCTION: Create hash value from symbol name.
|
||||||
*
|
*
|
||||||
* EXECUTION ENVIRONMENT:
|
* EXECUTION ENVIRONMENT:
|
||||||
* User mode.
|
* User mode.
|
||||||
*
|
*
|
||||||
* NOTES: Hash the symbol name using simple addition algorithm.
|
* NOTES: Hash the symbol name using simple addition algorithm.
|
||||||
* Make sure that the hash value is in range when it is returned.
|
* Make sure that the hash value is in range when it is returned.
|
||||||
*
|
*
|
||||||
* RETURNS: A hash value.
|
* RETURNS: A hash value.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static int
|
static int
|
||||||
hash (char *name) /* pointer to symbol */
|
hash (char *name) /* pointer to symbol */
|
||||||
{
|
{
|
||||||
int hashval = 0;
|
int hashval = 0;
|
||||||
|
|
||||||
while (*name)
|
while (*name)
|
||||||
hashval += *name++;
|
hashval += *name++;
|
||||||
|
|
||||||
return (hashval & HASHMAX);
|
return (hashval & HASHMAX);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue