/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* makedefs.c - version 1.0.2 */
/* construct definitions of object constants */
(void)fprintf(stderr
, "usage: makedefs file\n");
if ((fd
= open(argv
[1], 0)) < 0) {
skipuntil("objects[] = {");
for(sp
= string
; *sp
; sp
++)
if(*sp
== ' ' || *sp
== '\t' || *sp
== '-')
if(!strncmp(string
, "RIN_", 4)){
printf("#define %s u.uprops[%d].p_flgs\n",
for(sp
= string
; *sp
; sp
++) capitalize(sp
);
/* avoid trouble with stupid C preprocessors */
if(!strncmp(string
, "WORTHLESS_PIECE_OF_", 19))
printf("/* #define %s %d */\n", string
, index
);
printf("#define %s %d\n", string
, index
);
printf("\n#define CORPSE DEAD_HUMAN\n");
printf("#define LAST_GEM (JADE+1)\n");
printf("#define LAST_RING %d\n", propct
);
printf("#define NROFOBJECTS %d\n", index
-1);
char line
[LINSZ
], *lp
= line
, *lp0
= line
, *lpe
= line
;
register int n
= read(fd
, lp0
, (line
+LINSZ
)-lp0
);
printf("Input error.\n");
return((lp
== lpe
) ? 0 : *lp
++);
register char *sp0
, *sp1
;
printf("Cannot skipuntil %s\n", s
);
if(strlen(s
) > lpe
-lp
+1){
register char *lp1
, *lp2
;
while(lp2
!= lpe
) *lp1
++ = *lp2
++;
lp2
= lp0
; /* save value */
if(strlen(s
) > lpe
-lp
+1) {
printf("error in skipuntil");
while(*sp0
&& *sp0
== *sp1
) sp0
++, sp1
++;
int inbraces
= 0, inparens
= 0, stringseen
= 0, commaseen
= 0;
string
[0] = string
[4] = 0;
/* read until {...} or XXX(...) followed by ,
skip comment and #define lines
if(ip
< identif
+NSZ
-1) *ip
++ = ch
;
} while(letter(ch
) || digit(ch
));
while(ch
== ' ' || ch
== '\t') ch
= nextchar();
if(ch
== '(' && !inparens
&& !stringseen
)
if(!strcmp(identif
, "WAND") ||
!strcmp(identif
, "RING") ||
!strcmp(identif
, "POTION") ||
!strcmp(identif
, "SCROLL"))
(void) strncpy(string
, identif
, 3),
if((ch
= nextchar()) == '*')
if(inbraces
< 0) return(0);
/* watch for #define at begin of line */
if((ch
= nextchar()) == '#'){
/* skip until '\n' not preceded by '\\' */
} while(ch
!= '\n' || pch
== '\\');
if(!inparens
&& !inbraces
){
if(prefix
&& !string
[prefix
])
if(stringseen
) return(1);
printf("unexpected ,\n");
if((ch
= nextchar()) == '\\') ch
= nextchar();
printf("strange character denotation?\n");
register char *sp
= string
+ prefix
;
register int store
= (inbraces
|| inparens
)
&& !stringseen
++ && !commaseen
;
if(store
&& sp
< string
+STRSZ
)
} while(ch
!= '"' || pch
== '\\');
capitalize(sp
) register char *sp
; {
if('a' <= *sp
&& *sp
<= 'z') *sp
+= 'A'-'a';
letter(ch
) register char ch
; {
return( ('a' <= ch
&& ch
<= 'z') ||
('A' <= ch
&& ch
<= 'Z') );
digit(ch
) register char ch
; {
return( '0' <= ch
&& ch
<= '9' );