Mail Archives: djgpp/1996/02/11/09:09:29
I've been fighting with this for some time now. I hope someone can help.
basically, I can't get regex library calls to work. I currently have
djgpp112m4 installed. For what it's worth, this is on a Windows 95
machine.
The following simplified code works with gcc under Solaris 2.5 but not
under djgpp. It compiles and runs, but never finds any matches.
Everything I've found in the mail archive regarding regex says that
libgpl.a is needed. I've found that I also need libgpp.a.
#include <stdio.h>
#include <regex.h>
#include <string.h>
int main(int argc, char *argv[]) {
char *rresult, line[120];
FILE *fp;
if(argc < 2)
exit(1);
if(rresult = re_comp(argv[1])) {
fprintf(stderr, "error compiling %s as regular expression\n", regexstr);
exit(1);
}
if(argc >= 3) {
if((fp = fopen(argv[2], "r")) == NULL) {
fprintf(stderr, "Error opening %s\n", argv[2]);
exit(1);
}
} else {
fp = stdin;
}
while(fgets(line, 120, fp)) {
if(re_exec(line))
fprintf(stderr, "match: %s\n", line);
}
}
--
It doesn't get much simpler than that. any suggestions are appreciated.
thanks.
Larry Moss
moss AT pobox DOT com
--
Larry Moss, Programmer, Dept. of Ophthalmology, University of Rochester
moss AT cvs DOT rochester DOT edu, http://www.cvs.rochester.edu/people/l_moss/l_moss.html
- Raw text -