void version(char *progname, char *rcs_rev) { int major = -1; int minor = -1; char *where = NULL; char buf[5]; char nulls[5] = {'\000', '\000', '\000', '\000', '\000'}; int bufptr = 0; if(strchr(rcs_rev, ':') == NULL) { printf("%s, no RCS revision given.\n", progname); return; } where = strchr(rcs_rev, ' '); where++; while(where[0] != ' ') { if(where[0] != ' ' && where[0] != '.') { buf[bufptr++] = where[0]; } else if(where[0] == '.') { if(major == -1) { major = atoi(buf); } else if(minor == -1) { minor = atoi(buf); break; } bufptr = 0; memcpy(buf,nulls,5); } else break; where++; } fprintf(stderr,"%s version %d.%d\n",progname,major,minor); } #### sub version { my ($progname, $rcs_rev) = (@_); if($rcs_rev !~ /:/) { print "$progname, no RCS version given.\n"; return; } $rcs_rev =~ /Revision: (\d+)\.(\d+)/; my ($major, $minor) = ($1, $2); print "$progname version $major.$minor\n"; }