This is test.c in view mode; [Download] [Up]
{\rtf0\ansi{\fonttbl\f0\fswiss Helvetica;} \paperw11820 \paperh10160 \margl40 \margr40 {\colortbl;\red255\green0\blue0;\red0\green0\blue0;\red255\green109\blue0;\red0\green41\blue0;\red61\green0\blue0;} \pard\tx520\tx1060\tx1600\tx2120\tx2660\tx3200\tx3720\tx4260\tx4800\tx5320\f0\b0\i\ulnone\fs28\gray300\fc1\cf1 // test.c -- simple test program for GNU's regex \i0\gray0\fc2\cf2 \ \ \b #include \b0 <stdio.h>\ \b #include \b0 <stdlib.h>\ \b #include \b0 \gray551\fc3\cf3 "regex.h" \gray0\fc2\cf2 \ \ \b char \b0 string[] = \gray551\fc3\cf3 " #define x; int i;" \gray0\fc2\cf2 ;\ \ \fs36 int main(int argc, char **argv)\ \fs28 \{\ regex_t re;\ regmatch_t rm;\ \ \b if \b0 (regcomp(&re, \gray551\fc3\cf3 "[:space:]#define[:space:]" \gray0\fc2\cf2 , \gray93\fc4\cf4 REG_EXTENDED \gray0\fc2\cf2 | \gray93\fc4\cf4 REG_NEWLINE \gray0\fc2\cf2 )) \{\ printf( \gray551\fc3\cf3 "ERROR: regcomp() failed\\n" \gray0\fc2\cf2 );\ exit( \gray71\fc5\cf5 0 \gray0\fc2\cf2 );\ \}\ \b if \b0 (regexec(&re, string, \gray71\fc5\cf5 1 \gray0\fc2\cf2 , &rm, \gray71\fc5\cf5 0 \gray0\fc2\cf2 )) \{\ printf( \gray551\fc3\cf3 "ERROR: regexec() didn't match\\n" \gray0\fc2\cf2 );\ exit( \gray71\fc5\cf5 0 \gray0\fc2\cf2 );\ \}\ printf( \gray551\fc3\cf3 "start = %d\\n" \gray0\fc2\cf2 , rm.rm_so);\ printf( \gray551\fc3\cf3 "end = %d\\n" \gray0\fc2\cf2 , rm.rm_eo);\ string[rm.rm_eo] = \gray71\fc5\cf5 0 \gray0\fc2\cf2 ;\ printf( \gray551\fc3\cf3 "string = %s\\n" \gray0\fc2\cf2 , string + rm.rm_so);\ \b return \b0 \gray71\fc5\cf5 0 \gray0\fc2\cf2 ;\ \}\ }
These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.