mirror of
https://github.com/Mercury-Language/mercury.git
synced 2026-04-15 17:33:38 +00:00
Estimated hours taken: 1 runtime/mercury_getopt.c: runtime/mercury_getopt1.c: Add the files as produced by process_getopt. runtime/process_getopt: runtime/mercury_getopt.h: Avoid a warning if the environment already defines __GNU_LIBRARY__, and prevent this from omitting the entire bodies of the source files :-(. util/getopt.h: A copy of the old mercury_getopt.h for mkinit.c util/mkinit.c: Include getopt.h instead of mercury_getopt.h, since we want getopt(), not MR_getopt().
54 lines
1.2 KiB
Bash
Executable File
54 lines
1.2 KiB
Bash
Executable File
#!/bin/sh
|
|
|
|
chmod 644 mercury_getopt.h mercury_getopt.c mercury_getopt1.c
|
|
|
|
for file in getopt.h getopt.c getopt1.c
|
|
do
|
|
echo processing mercury_$file
|
|
cp GETOPT/$file mercury_$file
|
|
ex mercury_$file << END
|
|
g/#include/s/getopt/mercury_getopt/
|
|
g/\<getopt/s//MR_getopt/g
|
|
g/\<optarg/s//MR_optarg/g
|
|
g/\<optind/s//MR_optind/g
|
|
g/\<opterr/s//MR_opterr/g
|
|
g/\<optopt/s//MR_optopt/g
|
|
g/\<option/s//MR_option/g
|
|
g/\<_getopt/s//MR__getopt/g
|
|
g/#ifndef/s/ELIDE_CODE/XXXELIDE_CODEXXX/
|
|
w
|
|
q
|
|
END
|
|
done
|
|
|
|
echo finalizing mercury_getopt.h
|
|
ex mercury_getopt.h << END
|
|
1i
|
|
#undef __GNU_LIBRARY__
|
|
#define __GNU_LIBRARY__
|
|
.
|
|
w
|
|
q
|
|
END
|
|
|
|
echo finalizing mercury_getopt.c
|
|
ex mercury_getopt.c << END
|
|
1i
|
|
extern char *getenv(const char *);
|
|
.
|
|
g/nextchar/s//MR_nextchar/g
|
|
g/ordering/s//MR_ordering/g
|
|
g/posixly_correct/s//MR_posixly_correct/g
|
|
g/first_nonopt/s//MR_first_nonopt/g
|
|
g/last_nonopt/s//MR_last_nonopt/g
|
|
g/__getopt_initialized/s//MR____getopt_initialized/g
|
|
g/%s: MR_option/s//%s: option/g
|
|
g/%s: unrecognized MR_option/s//%s: unrecognized option/g
|
|
g/%s: illegal MR_option/s//%s: illegal option/g
|
|
g/%s: invalid MR_option/s//%s: invalid option/g
|
|
w
|
|
q
|
|
END
|
|
|
|
chmod 444 mercury_getopt.h mercury_getopt.c mercury_getopt1.c
|