[test-suite] r318521 - [test-suite] fix unix-smail test issue when linking statically
Petar Jovanovic via llvm-commits
llvm-commits at lists.llvm.org
Fri Nov 17 04:14:33 PST 2017
Author: petarj
Date: Fri Nov 17 04:14:33 2017
New Revision: 318521
URL: http://llvm.org/viewvc/llvm-project?rev=318521&view=rev
Log:
[test-suite] fix unix-smail test issue when linking statically
Test unix-smail fails to compile when --static flag is used. Add a prefix
to getopt, optind and opterr in order to avoid issue with libc while
linking.
Patch by Milos Stojanovic.
Differential Revision: https://reviews.llvm.org/D40075
Modified:
test-suite/trunk/MultiSource/Benchmarks/Prolangs-C/unix-smail/getopt.c
test-suite/trunk/MultiSource/Benchmarks/Prolangs-C/unix-smail/main.c
Modified: test-suite/trunk/MultiSource/Benchmarks/Prolangs-C/unix-smail/getopt.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/MultiSource/Benchmarks/Prolangs-C/unix-smail/getopt.c?rev=318521&r1=318520&r2=318521&view=diff
==============================================================================
--- test-suite/trunk/MultiSource/Benchmarks/Prolangs-C/unix-smail/getopt.c (original)
+++ test-suite/trunk/MultiSource/Benchmarks/Prolangs-C/unix-smail/getopt.c Fri Nov 17 04:14:33 2017
@@ -27,7 +27,7 @@
#include <strings.h>
/*LINTLIBRARY*/
-#define ERR(s, c) if(opterr){\
+#define ERR(s, c) if(unix_smail_opterr){\
extern int write();\
char errbuf[2];\
errbuf[0] = c; errbuf[1] = '\n';\
@@ -35,49 +35,49 @@
(void) write(2, s, (unsigned)strlen(s));\
(void) write(2, errbuf, 2);}
-int opterr = 1;
-int optind = 1;
+int unix_smail_opterr = 1;
+int unix_smail_optind = 1;
int optopt;
char *optarg;
#define EOF (-1)
-int getopt(int argc,char **argv,char *opts)
+int unix_smail_getopt(int argc,char **argv,char *opts)
{
static int sp = 1;
register int c;
register char *cp;
if(sp == 1)
- if(optind >= argc ||
- argv[optind][0] != '-' || argv[optind][1] == '\0')
+ if(unix_smail_optind >= argc ||
+ argv[unix_smail_optind][0] != '-' || argv[unix_smail_optind][1] == '\0')
return(EOF);
- else if(strcmp(argv[optind], "--") == NULL) {
- optind++;
+ else if(strcmp(argv[unix_smail_optind], "--") == NULL) {
+ unix_smail_optind++;
return(EOF);
}
- optopt = c = argv[optind][sp];
+ optopt = c = argv[unix_smail_optind][sp];
if(c == ':' || (cp=index(opts, c)) == NULL) {
ERR(": illegal option -- ", c);
- if(argv[optind][++sp] == '\0') {
- optind++;
+ if(argv[unix_smail_optind][++sp] == '\0') {
+ unix_smail_optind++;
sp = 1;
}
return('?');
}
if(*++cp == ':') {
- if(argv[optind][sp+1] != '\0')
- optarg = &argv[optind++][sp+1];
- else if(++optind >= argc) {
+ if(argv[unix_smail_optind][sp+1] != '\0')
+ optarg = &argv[unix_smail_optind++][sp+1];
+ else if(++unix_smail_optind >= argc) {
ERR(": option requires an argument -- ", c);
sp = 1;
return('?');
} else
- optarg = argv[optind++];
+ optarg = argv[unix_smail_optind++];
sp = 1;
} else {
- if(argv[optind][++sp] == '\0') {
+ if(argv[unix_smail_optind][++sp] == '\0') {
sp = 1;
- optind++;
+ unix_smail_optind++;
}
optarg = NULL;
}
Modified: test-suite/trunk/MultiSource/Benchmarks/Prolangs-C/unix-smail/main.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/MultiSource/Benchmarks/Prolangs-C/unix-smail/main.c?rev=318521&r1=318520&r2=318521&view=diff
==============================================================================
--- test-suite/trunk/MultiSource/Benchmarks/Prolangs-C/unix-smail/main.c (original)
+++ test-suite/trunk/MultiSource/Benchmarks/Prolangs-C/unix-smail/main.c Fri Nov 17 04:14:33 2017
@@ -40,7 +40,7 @@ static char *sccsid="@(#)main.c 2.5 (sm
#include <stdlib.h>
#include "defs.h"
-int getopt();
+int unix_smail_getopt();
int exitstat = 0; /* exit status, set by resolve, deliver */
@@ -114,7 +114,7 @@ int main(int argc,char *argv[])
char *optstr = "cdvArRlLH:h:p:u:q:a:n:m:f:F:";
extern char *optarg;
- extern int optind;
+ extern int unix_smail_optind;
/*
** see if we aren't invoked as rmail
@@ -132,7 +132,7 @@ int main(int argc,char *argv[])
/*
** Process command line arguments
*/
- while ((c = getopt(argc, argv, optstr)) != EOF) {
+ while ((c = unix_smail_getopt(argc, argv, optstr)) != EOF) {
switch ( c ) {
case 'd': debug = YES; break;
case 'v': debug = VERBOSE; break;
@@ -162,7 +162,7 @@ int main(int argc,char *argv[])
error( EX_USAGE, "valid flags are %s\n", optstr);
}
}
- if ( argc <= optind ) {
+ if ( argc <= unix_smail_optind ) {
error( EX_USAGE, "usage: %s [flags] address...\n", "smail" );
}
@@ -174,15 +174,15 @@ int main(int argc,char *argv[])
/*
** Spool the letter in a temporary file.
*/
- nargc = argc - optind;
+ nargc = argc - unix_smail_optind;
if(printaddr == 0) {
- spool(nargc, &argv[optind]);
+ spool(nargc, &argv[unix_smail_optind]);
}
/*
** Do aliasing and fullname resolution
*/
- nargv = alias(&nargc, &argv[optind]);
+ nargv = alias(&nargc, &argv[unix_smail_optind]);
/*
** Map argv addresses to <host, user, form, cost>.
More information about the llvm-commits
mailing list