Path: utzoo!mnetor!uunet!lll-winken!lll-lcc!ptsfa!cpro!asgard From: asgard@cpro.UUCP (J.R. Stoner) Newsgroups: comp.sources.d Subject: Re: HELP with vn Message-ID: <379@cpro.UUCP> Date: 22 Feb 88 23:16:22 GMT References: <6800@drutx.ATT.COM> Organization: CompuPro/VIASYN Corporation, Hayward, CA Lines: 249 From article <6800@drutx.ATT.COM>, by clive@drutx.ATT.COM (Clive Steward): > From article <163@magic4.UUCP>, by eric@magic4.UUCP (Eric Kozowski): >> Could someone please help me with this problem. Here is the output >> from a make on vn: >> undefined first referenced >> symbol in file >> regcmp reader.o >> regex reader.o >> I'm running Sys V 3.1 on an AT&T 3B2/400. Please help. > Here is how to fix such things. > Take your Unix Manuals. Look up regcmp in the permuted index. You'll find > man pages listed in section 3, which is in the Programmer Reference Manual. > There you will see that 'this routine is kept in /lib/libPW.a'. > If you are familiar with ld, or read the man pages (Section 1, User > Reference Manual), you will know that such a library is automatically > included by putting the shorter -lPW on the cc command line. > So, let's edit the Makefile. Comment out the LIBS definition, and > replace it as follows: > #LIBS = -ltermcap > LIBS = -lcurses -lPW > We'll do one thing more; curses is a later replacement for termcap, > and usually a bit better, so we substitute that library as well. Not only that, but vanilla SYS5 curses has the termcap functions in libcurses. > If you turn out to have screen problems for some reason, you can alternatively > use: > LIBS = -lcurses -lPW > Once you've edited the Makefile, re-make vn. > This should work. Hope you have good fortune with it. This will get you past linking the program but the first attempt to match a regular expression might just cause a segmentation violation. This is the patch to reg.c which makes vanilla regex work with vn: [Note - you must also REMOVE the -Dfree=regfree from your CFLAGS line in your Makefile]. *** oreg.c Fri Feb 5 21:30:56 1988 --- reg.c Mon Feb 22 14:36:01 1988 *************** *** 45,50 } } char *regcmp(str) char *str; { --- 45,65 ----- } } + #ifdef SYSV + + char *re_expbuf; + char *re_ss; + extern char *malloc(); + #define INIT char *sp = instring; + #define GETC() (*sp++) + #define PEEKC() (*sp) + #define UNGETC(c) (--sp) + #define RETURN(c) re_ss = c; return((char *)0) + #define ERROR(c) return((char *)c) + #include + + #endif + char *regcmp(str) char *str; { *************** *** 50,56 { int i; char *str_store(); - char *re_comp(); if (re_comp(str) != NULL) { --- 65,70 ----- { int i; char *str_store(); #ifdef SYSV *************** *** 52,57 char *str_store(); char *re_comp(); if (re_comp(str) != NULL) { Compiled = NULL; /* make sure we're OK */ --- 66,85 ----- int i; char *str_store(); + #ifdef SYSV + + char *compile(); + if(re_expbuf == (char *)NULL) + { + re_expbuf = (char *)malloc(512); + if(re_expbuf == (char *)NULL) + printex("regcmp: memory allocation failure"); + } + if(compile(str,re_expbuf,re_expbuf + 512,'\0') != (char *)0) + + #else + + char *re_comp(); if (re_comp(str) != NULL) #endif *************** *** 53,58 char *re_comp(); if (re_comp(str) != NULL) { Compiled = NULL; /* make sure we're OK */ return(NULL); --- 81,89 ----- char *re_comp(); if (re_comp(str) != NULL) + + #endif + { Compiled = NULL; /* make sure we're OK */ return(NULL); *************** *** 87,92 if (cmp == Compiled) { if (re_exec(str)) return(str); return (NULL); --- 118,130 ----- if (cmp == Compiled) { + + #ifdef SYSV + + if(step(str,re_expbuf) != 0) + + #else + if (re_exec(str)) #endif *************** *** 88,93 if (cmp == Compiled) { if (re_exec(str)) return(str); return (NULL); } --- 126,134 ----- #else if (re_exec(str)) + + #endif + return(str); return (NULL); } *************** *** 101,107 if (Compiled == NULL) printex ("regex: bad pointer"); ! re_comp(Compiled->regstr); if (re_exec(str)) return(str); --- 142,148 ----- if (Compiled == NULL) printex ("regex: bad pointer"); ! #ifdef SYSV (void)compile(str,re_expbuf,re_expbuf + 512,'\0'); if(step(str,re_expbuf) != 0) *************** *** 103,108 re_comp(Compiled->regstr); if (re_exec(str)) return(str); --- 144,155 ----- #ifdef SYSV + (void)compile(str,re_expbuf,re_expbuf + 512,'\0'); + if(step(str,re_expbuf) != 0) + + #else + + re_comp(Compiled->regstr); if (re_exec(str)) #endif *************** *** 104,109 re_comp(Compiled->regstr); if (re_exec(str)) return(str); return(NULL); --- 151,159 ----- re_comp(Compiled->regstr); if (re_exec(str)) + + #endif + return(str); return(NULL); [I hope this works out for you. It makes vn work in a Microport 286 kernel.] -- "To prevent having to tell fools to RTFM don't let on you WTFM to begin with." J.R. Stoner asgard@cpro.UUCP asgard@wotan.UUCP P.S. I help CompuPro make computers. They do not help me make my opinions.