Run through clang-format.
This commit is contained in:
		
							parent
							
								
									11ea3a2fe1
								
							
						
					
					
						commit
						4b7fc5e233
					
				
					 1 changed files with 421 additions and 299 deletions
				
			
		
							
								
								
									
										338
									
								
								util/ack/main.c
									
										
									
									
									
								
							
							
						
						
									
										338
									
								
								util/ack/main.c
									
										
									
									
									
								
							|  | @ -35,7 +35,8 @@ static void scanneeds(void); | ||||||
| static void setneeds(const char*, int); | static void setneeds(const char*, int); | ||||||
| static void noodstop(int); | static void noodstop(int); | ||||||
| 
 | 
 | ||||||
| int main(int argc, char **argv) { | int main(int argc, char** argv) | ||||||
|  | { | ||||||
| 	register list_elem* elem; | 	register list_elem* elem; | ||||||
| 	register char* frontend; | 	register char* frontend; | ||||||
| 	register int* n_sig; | 	register int* n_sig; | ||||||
|  | @ -44,19 +45,25 @@ int main(int argc, char **argv) { | ||||||
| 	progname = argv[0]; | 	progname = argv[0]; | ||||||
| 	varinit(); | 	varinit(); | ||||||
| 	vieuwargs(argc, argv); | 	vieuwargs(argc, argv); | ||||||
| 	if ( (frontend=getenv("ACKFE")) ) { | 	if ((frontend = getenv("ACKFE"))) | ||||||
|  | 	{ | ||||||
| 		setlist(frontend); | 		setlist(frontend); | ||||||
| 	} else { | 	} | ||||||
|  | 	else | ||||||
|  | 	{ | ||||||
| 		setlist(FRONTENDS); | 		setlist(FRONTENDS); | ||||||
| 	} | 	} | ||||||
| 	if ( callname ) { | 	if (callname) | ||||||
| 		if ( machine ) { | 	{ | ||||||
|  | 		if (machine) | ||||||
|  | 		{ | ||||||
| 			fuerror("can not produce code for both %s and %s", | 			fuerror("can not produce code for both %s and %s", | ||||||
| 			    callname, machine); | 			    callname, machine); | ||||||
| 		} | 		} | ||||||
| 		machine = callname; | 		machine = callname; | ||||||
| 	} | 	} | ||||||
| 	if ( !machine && ! (machine=getenv("ACKM")) ) { | 	if (!machine && !(machine = getenv("ACKM"))) | ||||||
|  | 	{ | ||||||
| #ifdef ACKM | #ifdef ACKM | ||||||
| 		machine = ACKM; /* The default machine */ | 		machine = ACKM; /* The default machine */ | ||||||
| #else | #else | ||||||
|  | @ -65,40 +72,54 @@ int main(int argc, char **argv) { | ||||||
| 	} | 	} | ||||||
| 	setlist(machine); | 	setlist(machine); | ||||||
| 	/* Find the linker, needed for argument building */ | 	/* Find the linker, needed for argument building */ | ||||||
| 	scanlist(l_first(tr_list),elem) { | 	scanlist(l_first(tr_list), elem) | ||||||
| 		if ( t_cont(*elem)->t_linker ) { | 	{ | ||||||
|  | 		if (t_cont(*elem)->t_linker) | ||||||
|  | 		{ | ||||||
| 			linker = t_cont(*elem); | 			linker = t_cont(*elem); | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
| 	transini(); | 	transini(); | ||||||
| 	scanneeds(); | 	scanneeds(); | ||||||
| 	sprintf(template, TMPNAME, getpid()); | 	sprintf(template, TMPNAME, getpid()); | ||||||
| 	if ( n_error && !k_flag ) exit(n_error) ; | 	if (n_error && !k_flag) | ||||||
|  | 		exit(n_error); | ||||||
| 
 | 
 | ||||||
| 	for ( n_sig=sigs ; *n_sig ; n_sig++ ) { | 	for (n_sig = sigs; *n_sig; n_sig++) | ||||||
| 		if ( signal(*n_sig,noodstop)==SIG_IGN ) { | 	{ | ||||||
|  | 		if (signal(*n_sig, noodstop) == SIG_IGN) | ||||||
|  | 		{ | ||||||
| 			signal(*n_sig, SIG_IGN); | 			signal(*n_sig, SIG_IGN); | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	scanlist ( l_first(arguments), elem ) { | 	scanlist(l_first(arguments), elem) | ||||||
|  | 	{ | ||||||
| 		arg_count++; | 		arg_count++; | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	scanlist ( l_first(arguments), elem ) { | 	scanlist(l_first(arguments), elem) | ||||||
| 		if ( !process(l_content(*elem)) && !k_flag ) exit(1) ; | 	{ | ||||||
|  | 		if (!process(l_content(*elem)) && !k_flag) | ||||||
|  | 			exit(1); | ||||||
| 	} | 	} | ||||||
| 	orig.p_path = (char*)0; | 	orig.p_path = (char*)0; | ||||||
| 	if ( !rts ) rts="." ; | 	if (!rts) | ||||||
|  | 		rts = "."; | ||||||
| 	setsvar(keeps(RTS), rts); | 	setsvar(keeps(RTS), rts); | ||||||
| 	if ( linker ) getmapflags(linker) ; | 	if (linker) | ||||||
|  | 		getmapflags(linker); | ||||||
| 
 | 
 | ||||||
| 	scanlist(l_first(tr_list),elem) { | 	scanlist(l_first(tr_list), elem) | ||||||
|  | 	{ | ||||||
| 		phase = t_cont(*elem); | 		phase = t_cont(*elem); | ||||||
| 		if ( phase->t_combine && phase->t_do ) { | 		if (phase->t_combine && phase->t_do) | ||||||
| 			if ( phase->t_blocked ) { | 		{ | ||||||
|  | 			if (phase->t_blocked) | ||||||
|  | 			{ | ||||||
| #ifdef DEBUG | #ifdef DEBUG | ||||||
| 				if ( debug ) { | 				if (debug) | ||||||
|  | 				{ | ||||||
| 					vprint("phase %s is blocked\n", | 					vprint("phase %s is blocked\n", | ||||||
| 					    phase->t_name); | 					    phase->t_name); | ||||||
| 				} | 				} | ||||||
|  | @ -109,35 +130,45 @@ int main(int argc, char **argv) { | ||||||
| 			orig.p_keep = YES; | 			orig.p_keep = YES; | ||||||
| 			orig.p_keeps = NO; | 			orig.p_keeps = NO; | ||||||
| 			orig.p_path = phase->t_origname; | 			orig.p_path = phase->t_origname; | ||||||
| 			if ( p_basename ) throws(p_basename) ; | 			if (p_basename) | ||||||
| 			if ( orig.p_path ) { | 				throws(p_basename); | ||||||
|  | 			if (orig.p_path) | ||||||
|  | 			{ | ||||||
| 				p_basename = keeps(ack_basename(orig.p_path)); | 				p_basename = keeps(ack_basename(orig.p_path)); | ||||||
| 			} else { | 			} | ||||||
|  | 			else | ||||||
|  | 			{ | ||||||
| 				p_basename = 0; | 				p_basename = 0; | ||||||
| 			} | 			} | ||||||
| 			if ( !startrf(phase) && !k_flag ) exit(1) ; | 			if (!startrf(phase) && !k_flag) | ||||||
|  | 				exit(1); | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	if ( n_error ) exit(n_error) ; | 	if (n_error) | ||||||
|  | 		exit(n_error); | ||||||
| 
 | 
 | ||||||
| 	exit(0); | 	exit(0); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| static char *srcvar(void) { | static char* srcvar(void) | ||||||
|  | { | ||||||
| 	return orig.p_path; | 	return orig.p_path; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| static char *getsuffix(void) { | static char* getsuffix(void) | ||||||
|  | { | ||||||
| 	return strrchr(orig.p_path, SUFCHAR); | 	return strrchr(orig.p_path, SUFCHAR); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| static void varinit(void) { | static void varinit(void) | ||||||
|  | { | ||||||
| 	/* initialize the string variables */ | 	/* initialize the string variables */ | ||||||
| 	register char* envstr; | 	register char* envstr; | ||||||
| 	extern char* em_dir; | 	extern char* em_dir; | ||||||
| 
 | 
 | ||||||
| 	if ( envstr=getenv("ACKDIR") ) { | 	if (envstr = getenv("ACKDIR")) | ||||||
|  | 	{ | ||||||
| 		em_dir = keeps(envstr); | 		em_dir = keeps(envstr); | ||||||
| 	} | 	} | ||||||
| 	setsvar(keeps(HOME), em_dir); | 	setsvar(keeps(HOME), em_dir); | ||||||
|  | @ -147,7 +178,8 @@ static void varinit(void) { | ||||||
| 
 | 
 | ||||||
| /************************* flag processing ***********************/ | /************************* flag processing ***********************/ | ||||||
| 
 | 
 | ||||||
| void vieuwargs(int argc, char **argv) { | void vieuwargs(int argc, char** argv) | ||||||
|  | { | ||||||
| 	register char* argp; | 	register char* argp; | ||||||
| 	register int nextarg; | 	register int nextarg; | ||||||
| 	register int eaten; | 	register int eaten; | ||||||
|  | @ -157,10 +189,12 @@ void vieuwargs(int argc, char **argv) { | ||||||
| 
 | 
 | ||||||
| 	nextarg = 1; | 	nextarg = 1; | ||||||
| 
 | 
 | ||||||
| 	while ( nextarg<argc ) { | 	while (nextarg < argc) | ||||||
|  | 	{ | ||||||
| 		argp = argv[nextarg]; | 		argp = argv[nextarg]; | ||||||
| 		nextarg++; | 		nextarg++; | ||||||
| 		if ( argp[0]!='-' || argp[1]=='l' ) { | 		if (argp[0] != '-' || argp[1] == 'l') | ||||||
|  | 		{ | ||||||
| 			/* Not a flag, or a library */ | 			/* Not a flag, or a library */ | ||||||
| 			l_add(&arguments, argp); | 			l_add(&arguments, argp); | ||||||
| 			continue; | 			continue; | ||||||
|  | @ -169,74 +203,105 @@ void vieuwargs(int argc, char **argv) { | ||||||
| 		/* Flags */ | 		/* Flags */ | ||||||
| 		hide = NO; /* Do not hide this flags to the phases */ | 		hide = NO; /* Do not hide this flags to the phases */ | ||||||
| 		eaten = 0; /* Did not 'eat' tail of flag yet */ | 		eaten = 0; /* Did not 'eat' tail of flag yet */ | ||||||
| 		switch ( argp[1] ) { | 		switch (argp[1]) | ||||||
| 	   case 'm':    if ( machine ) fuerror("Two machines?") ; | 		{ | ||||||
|  | 			case 'm': | ||||||
|  | 				if (machine) | ||||||
|  | 					fuerror("Two machines?"); | ||||||
| 				machine = &argp[2]; | 				machine = &argp[2]; | ||||||
| 			if (*machine == '\0') { | 				if (*machine == '\0') | ||||||
|  | 				{ | ||||||
| 					fuerror("-m needs machine name"); | 					fuerror("-m needs machine name"); | ||||||
| 				} | 				} | ||||||
| 				eaten = 1; | 				eaten = 1; | ||||||
| 				break; | 				break; | ||||||
| 	   case 'o':    if ( nextarg>=argc ) { | 			case 'o': | ||||||
|  | 				if (nextarg >= argc) | ||||||
|  | 				{ | ||||||
| 					fuerror("-o can't be the last flag"); | 					fuerror("-o can't be the last flag"); | ||||||
| 				} | 				} | ||||||
| 			if ( outfile ) fuerror("Two results?") ; | 				if (outfile) | ||||||
|  | 					fuerror("Two results?"); | ||||||
| 				outfile = argv[nextarg++]; | 				outfile = argv[nextarg++]; | ||||||
| 				hide = YES; | 				hide = YES; | ||||||
| 				break; | 				break; | ||||||
| 	   case 'O':    Optlevel = atoi(&argp[2]); | 			case 'O': | ||||||
| 			if (! Optlevel) Optlevel = 1; | 				Optlevel = atoi(&argp[2]); | ||||||
|  | 				if (!Optlevel) | ||||||
|  | 					Optlevel = 1; | ||||||
| 				Optlist = &argp[2]; | 				Optlist = &argp[2]; | ||||||
| 				eaten = 1; | 				eaten = 1; | ||||||
| 				break; | 				break; | ||||||
| 	   case 'v':    if ( argp[2] ) { | 			case 'v': | ||||||
|  | 				if (argp[2]) | ||||||
|  | 				{ | ||||||
| 					v_flag += atoi(&argp[2]); | 					v_flag += atoi(&argp[2]); | ||||||
| 					eaten = 1; | 					eaten = 1; | ||||||
| 			} else { | 				} | ||||||
|  | 				else | ||||||
|  | 				{ | ||||||
| 					v_flag++; | 					v_flag++; | ||||||
| 				} | 				} | ||||||
| #ifdef DEBUG | #ifdef DEBUG | ||||||
| 	   		if ( v_flag>=3 ) debug=v_flag-2 ; | 				if (v_flag >= 3) | ||||||
|  | 					debug = v_flag - 2; | ||||||
| #endif | #endif | ||||||
| 				break; | 				break; | ||||||
| 	   case 'c':    if ( stopsuffix ) fuerror("Two -c flags") ; | 			case 'c': | ||||||
| 			stopsuffix= &argp[2]; eaten=1; | 				if (stopsuffix) | ||||||
| 			if ( *stopsuffix && *stopsuffix!=SUFCHAR ) { | 					fuerror("Two -c flags"); | ||||||
|  | 				stopsuffix = &argp[2]; | ||||||
|  | 				eaten = 1; | ||||||
|  | 				if (*stopsuffix && *stopsuffix != SUFCHAR) | ||||||
|  | 				{ | ||||||
| 					fuerror("-c flag has invalid tail"); | 					fuerror("-c flag has invalid tail"); | ||||||
| 				} | 				} | ||||||
| 				break; | 				break; | ||||||
| 	   case 'k':    k_flag++ ; | 			case 'k': | ||||||
|  | 				k_flag++; | ||||||
| 				break; | 				break; | ||||||
| 	   case 't':    t_flag++ ; | 			case 't': | ||||||
|  | 				t_flag++; | ||||||
| 				break; | 				break; | ||||||
| 	   case 'R':    eaten=1; | 			case 'R': | ||||||
|  | 				eaten = 1; | ||||||
| 				break; | 				break; | ||||||
| 	   case 'r':    if ( argp[2]!=SUFCHAR ) { | 			case 'r': | ||||||
|  | 				if (argp[2] != SUFCHAR) | ||||||
|  | 				{ | ||||||
| 					error("-r must be followed by %c", SUFCHAR); | 					error("-r must be followed by %c", SUFCHAR); | ||||||
| 				} | 				} | ||||||
| 				l_add(&tail_list, &argp[2]); | 				l_add(&tail_list, &argp[2]); | ||||||
| 				eaten = 1; | 				eaten = 1; | ||||||
| 				break; | 				break; | ||||||
| 	   case '.':    if ( rts ) { | 			case '.': | ||||||
|  | 				if (rts) | ||||||
|  | 				{ | ||||||
| 					if (strcmp(rts, &argp[1]) != 0) | 					if (strcmp(rts, &argp[1]) != 0) | ||||||
| 						fuerror("Two run-time systems?"); | 						fuerror("Two run-time systems?"); | ||||||
| 			} else { | 				} | ||||||
|  | 				else | ||||||
|  | 				{ | ||||||
| 					rts = &argp[1]; | 					rts = &argp[1]; | ||||||
| 					l_add(&head_list, rts); | 					l_add(&head_list, rts); | ||||||
| 					l_add(&tail_list, rts); | 					l_add(&tail_list, rts); | ||||||
| 				} | 				} | ||||||
| 				eaten = 1; | 				eaten = 1; | ||||||
| 				break; | 				break; | ||||||
| 	   case  0 :    nill_flag++ ; eaten++ ; | 			case 0: | ||||||
|  | 				nill_flag++; | ||||||
|  | 				eaten++; | ||||||
| 				hide = YES; | 				hide = YES; | ||||||
| 				break; | 				break; | ||||||
| 	   case 'w':    w_flag++; | 			case 'w': | ||||||
|  | 				w_flag++; | ||||||
| 				break; | 				break; | ||||||
| 			default: /* The flag is not recognized,
 | 			default: /* The flag is not recognized,
 | ||||||
| 			   put it on the list for the sub-processes | 			   put it on the list for the sub-processes | ||||||
| 			*/ | 			*/ | ||||||
| #ifdef DEBUG | #ifdef DEBUG | ||||||
| 			if ( debug ) { | 				if (debug) | ||||||
|  | 				{ | ||||||
| 					vprint("Flag %s: phase dependent\n", argp); | 					vprint("Flag %s: phase dependent\n", argp); | ||||||
| 				} | 				} | ||||||
| #endif | #endif | ||||||
|  | @ -244,30 +309,39 @@ void vieuwargs(int argc, char **argv) { | ||||||
| 				eaten = 1; | 				eaten = 1; | ||||||
| 				hide = YES; | 				hide = YES; | ||||||
| 		} | 		} | ||||||
| 		if ( !hide ) { | 		if (!hide) | ||||||
|  | 		{ | ||||||
| 			register char* tokeep; | 			register char* tokeep; | ||||||
| 			tokeep = keeps(argp); | 			tokeep = keeps(argp); | ||||||
| 			if ( argp[1]=='R' ) { | 			if (argp[1] == 'R') | ||||||
|  | 			{ | ||||||
| 				l_add(&R_list, tokeep); | 				l_add(&R_list, tokeep); | ||||||
| 			} else { | 			} | ||||||
|  | 			else | ||||||
|  | 			{ | ||||||
| 				*tokeep |= NO_SCAN; | 				*tokeep |= NO_SCAN; | ||||||
| 			} | 			} | ||||||
| 			l_add(&flags, tokeep); | 			l_add(&flags, tokeep); | ||||||
| 		} | 		} | ||||||
| 		if ( argp[2] && !eaten ) { | 		if (argp[2] && !eaten) | ||||||
|  | 		{ | ||||||
| 			werror("Unexpected characters at end of %s", argp); | 			werror("Unexpected characters at end of %s", argp); | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
| 	return; | 	return; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| static void firstarg(char *argp) { | static void firstarg(char* argp) | ||||||
|  | { | ||||||
| 	register char* name; | 	register char* name; | ||||||
| 
 | 
 | ||||||
| 	name = strrchr(argp, '/'); | 	name = strrchr(argp, '/'); | ||||||
| 	if ( name && *(name+1) ) { | 	if (name && *(name + 1)) | ||||||
|  | 	{ | ||||||
| 		name++; | 		name++; | ||||||
| 	} else { | 	} | ||||||
|  | 	else | ||||||
|  | 	{ | ||||||
| 		name = argp; | 		name = argp; | ||||||
| 	} | 	} | ||||||
| 	callname = name; | 	callname = name; | ||||||
|  | @ -275,40 +349,51 @@ static void firstarg(char *argp) { | ||||||
| 
 | 
 | ||||||
| /************************* argument processing ***********************/ | /************************* argument processing ***********************/ | ||||||
| 
 | 
 | ||||||
| static int process(char *arg) { | static int process(char* arg) | ||||||
|  | { | ||||||
| 	/* Process files & library arguments */ | 	/* Process files & library arguments */ | ||||||
| 	trf* phase; | 	trf* phase; | ||||||
| 	register trf* tmp; | 	register trf* tmp; | ||||||
| 
 | 
 | ||||||
| #ifdef DEBUG | #ifdef DEBUG | ||||||
| 	if ( debug ) vprint("Processing %s\n",arg) ; | 	if (debug) | ||||||
|  | 		vprint("Processing %s\n", arg); | ||||||
| #endif | #endif | ||||||
| 	p_suffix = strrchr(arg, SUFCHAR); | 	p_suffix = strrchr(arg, SUFCHAR); | ||||||
| 	orig.p_keep = YES; /* Don't throw away the original ! */ | 	orig.p_keep = YES; /* Don't throw away the original ! */ | ||||||
| 	orig.p_keeps = NO; | 	orig.p_keeps = NO; | ||||||
| 	orig.p_path = arg; | 	orig.p_path = arg; | ||||||
| 	if ( arg[0]=='-' || !p_suffix ) { | 	if (arg[0] == '-' || !p_suffix) | ||||||
| 		if ( linker ) add_input(&orig,linker) ; | 	{ | ||||||
|  | 		if (linker) | ||||||
|  | 			add_input(&orig, linker); | ||||||
| 		return 1; | 		return 1; | ||||||
| 	} | 	} | ||||||
| 	if ( p_basename ) throws(p_basename) ; | 	if (p_basename) | ||||||
|  | 		throws(p_basename); | ||||||
| 	p_basename = keeps(ack_basename(arg)); | 	p_basename = keeps(ack_basename(arg)); | ||||||
| 	/* Try to find a path through the transformations */ | 	/* Try to find a path through the transformations */ | ||||||
| 	switch( getpath(&phase) ) { | 	switch (getpath(&phase)) | ||||||
|  | 	{ | ||||||
| 		case F_NOPATH: | 		case F_NOPATH: | ||||||
| 			error("Cannot produce the desired file from %s", arg); | 			error("Cannot produce the desired file from %s", arg); | ||||||
| 		if ( linker ) add_input(&orig,linker) ; | 			if (linker) | ||||||
|  | 				add_input(&orig, linker); | ||||||
| 			return 1; | 			return 1; | ||||||
| 		case F_NOMATCH: | 		case F_NOMATCH: | ||||||
| 		if ( stopsuffix ) werror("Unknown suffix in %s",arg) ; | 			if (stopsuffix) | ||||||
| 		if ( linker ) add_input(&orig,linker) ; | 				werror("Unknown suffix in %s", arg); | ||||||
|  | 			if (linker) | ||||||
|  | 				add_input(&orig, linker); | ||||||
| 			return 1; | 			return 1; | ||||||
| 		case F_OK: | 		case F_OK: | ||||||
| 			break; | 			break; | ||||||
| 	} | 	} | ||||||
| 	if ( !phase ) return 1 ; | 	if (!phase) | ||||||
|  | 		return 1; | ||||||
| 	for (tmp = phase; tmp; tmp = tmp->t_next) | 	for (tmp = phase; tmp; tmp = tmp->t_next) | ||||||
| 	if ( !tmp->t_visited ) { | 		if (!tmp->t_visited) | ||||||
|  | 		{ | ||||||
| 			/* The flags are set up once.
 | 			/* The flags are set up once.
 | ||||||
| 		   At the first time each phase is in a list. | 		   At the first time each phase is in a list. | ||||||
| 		   The program name and flags may already be touched | 		   The program name and flags may already be touched | ||||||
|  | @ -318,65 +403,83 @@ static int process(char *arg) { | ||||||
| 			if (tmp->t_priority < 0) | 			if (tmp->t_priority < 0) | ||||||
| 				werror("Using phase %s (negative priority)", | 				werror("Using phase %s (negative priority)", | ||||||
| 				    tmp->t_name); | 				    tmp->t_name); | ||||||
| 		if ( !rts && tmp->t_rts ) rts= tmp->t_rts ; | 			if (!rts && tmp->t_rts) | ||||||
| 		if ( tmp->t_needed ) { | 				rts = tmp->t_rts; | ||||||
|  | 			if (tmp->t_needed) | ||||||
|  | 			{ | ||||||
| 				add_head(tmp->t_needed); | 				add_head(tmp->t_needed); | ||||||
| 				add_tail(tmp->t_needed); | 				add_tail(tmp->t_needed); | ||||||
| 			} | 			} | ||||||
| 		} | 		} | ||||||
| 	if ( phase->t_combine ) { | 	if (phase->t_combine) | ||||||
|  | 	{ | ||||||
| 		add_input(&orig, phase); | 		add_input(&orig, phase); | ||||||
| 		return 1; | 		return 1; | ||||||
| 	} | 	} | ||||||
| 	in = orig; | 	in = orig; | ||||||
| 	if ( !nill_flag && arg_count > 1 ) { | 	if (!nill_flag && arg_count > 1) | ||||||
|  | 	{ | ||||||
| 		printf("%s\n", arg); | 		printf("%s\n", arg); | ||||||
| 	} | 	} | ||||||
| 	return startrf(phase); | 	return startrf(phase); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| static int startrf(trf *first) { | static int startrf(trf* first) | ||||||
|  | { | ||||||
| 	/* Start the transformations at the indicated phase */ | 	/* Start the transformations at the indicated phase */ | ||||||
| 	register trf* phase; | 	register trf* phase; | ||||||
| 
 | 
 | ||||||
| 	phase = first; | 	phase = first; | ||||||
| 	for(;;) { | 	for (;;) | ||||||
|  | 	{ | ||||||
| 		int do_preprocess = 0; | 		int do_preprocess = 0; | ||||||
| 		int only_prep = 0; | 		int only_prep = 0; | ||||||
| 
 | 
 | ||||||
| 		switch ( phase->t_prep ) { | 		switch (phase->t_prep) | ||||||
|  | 		{ | ||||||
| 			/* BEWARE, sign extension */ | 			/* BEWARE, sign extension */ | ||||||
| 		case NO :    break ; | 			case NO: | ||||||
| 		default :    if ( !mayprep() ) break ; | 				break; | ||||||
| 		case YES:    do_preprocess = 1; | 			default: | ||||||
|  | 				if (!mayprep()) | ||||||
|  | 					break; | ||||||
|  | 			case YES: | ||||||
|  | 				do_preprocess = 1; | ||||||
| 				break; | 				break; | ||||||
| 		} | 		} | ||||||
| 		if ( cpp_trafo && stopsuffix && | 		if (cpp_trafo && stopsuffix && strcmp(cpp_trafo->t_out, stopsuffix) == 0) | ||||||
| 		     strcmp(cpp_trafo->t_out,stopsuffix)==0 ) { | 		{ | ||||||
| 			/* user explicitly asked for preprocessing */ | 			/* user explicitly asked for preprocessing */ | ||||||
| 			do_preprocess = 1; | 			do_preprocess = 1; | ||||||
| 			only_prep = 1; | 			only_prep = 1; | ||||||
| 		} | 		} | ||||||
| 
 | 
 | ||||||
| 		if (do_preprocess && !transform(cpp_trafo) ) { | 		if (do_preprocess && !transform(cpp_trafo)) | ||||||
|  | 		{ | ||||||
| 			n_error++; | 			n_error++; | ||||||
| #ifdef DEBUG | #ifdef DEBUG | ||||||
| 			vprint("Pre-processor failed\n"); | 			vprint("Pre-processor failed\n"); | ||||||
| #endif | #endif | ||||||
| 			return 0; | 			return 0; | ||||||
| 		} | 		} | ||||||
| 		if ( only_prep ) { | 		if (only_prep) | ||||||
|  | 		{ | ||||||
| 			break; | 			break; | ||||||
| 		} | 		} | ||||||
| 		if ( !transform(phase) ) { | 		if (!transform(phase)) | ||||||
|  | 		{ | ||||||
| 			n_error++; | 			n_error++; | ||||||
| 			block(phase->t_next); | 			block(phase->t_next); | ||||||
| #ifdef DEBUG | #ifdef DEBUG | ||||||
| 			if ( debug ) { | 			if (debug) | ||||||
| 				if ( !orig.p_path ) { | 			{ | ||||||
|  | 				if (!orig.p_path) | ||||||
|  | 				{ | ||||||
| 					vprint("phase %s failed\n", | 					vprint("phase %s failed\n", | ||||||
| 					    phase->t_name); | 					    phase->t_name); | ||||||
| 				} else { | 				} | ||||||
|  | 				else | ||||||
|  | 				{ | ||||||
| 					vprint("phase %s for %s failed\n", | 					vprint("phase %s for %s failed\n", | ||||||
| 					    phase->t_name, orig.p_path); | 					    phase->t_name, orig.p_path); | ||||||
| 				} | 				} | ||||||
|  | @ -386,20 +489,27 @@ static int startrf(trf *first) { | ||||||
| 		} | 		} | ||||||
| 		first = NO; | 		first = NO; | ||||||
| 		phase = phase->t_next; | 		phase = phase->t_next; | ||||||
| 		if ( !phase ) { | 		if (!phase) | ||||||
|  | 		{ | ||||||
| #ifdef DEBUG | #ifdef DEBUG | ||||||
| if ( debug ) vprint("Transformation sequence complete for %s\n", | 			if (debug) | ||||||
|  | 				vprint("Transformation sequence complete for %s\n", | ||||||
| 				    orig.p_path); | 				    orig.p_path); | ||||||
| #endif | #endif | ||||||
| 			/* No more work on this file */ | 			/* No more work on this file */ | ||||||
| 			if ( !in.p_keep ) { | 			if (!in.p_keep) | ||||||
|  | 			{ | ||||||
| 				fatal("attempt to discard the result file"); | 				fatal("attempt to discard the result file"); | ||||||
| 			} | 			} | ||||||
| 			if ( in.p_keeps ) throws(in.p_path) ; | 			if (in.p_keeps) | ||||||
| 			in.p_keep=NO ; in.p_keeps=NO ; in.p_path= (char *) 0 ; | 				throws(in.p_path); | ||||||
|  | 			in.p_keep = NO; | ||||||
|  | 			in.p_keeps = NO; | ||||||
|  | 			in.p_path = (char*)0; | ||||||
| 			return 1; | 			return 1; | ||||||
| 		} | 		} | ||||||
| 		if ( phase->t_combine ) { | 		if (phase->t_combine) | ||||||
|  | 		{ | ||||||
| 			add_input(&in, phase); | 			add_input(&in, phase); | ||||||
| 			break; | 			break; | ||||||
| 		} | 		} | ||||||
|  | @ -407,27 +517,34 @@ if ( debug ) vprint("Transformation sequence complete for %s\n", | ||||||
| 	return 1; | 	return 1; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| static void block(trf *first) { | static void block(trf* first) | ||||||
|  | { | ||||||
| 	/* One of the input files of this phase could not be produced,
 | 	/* One of the input files of this phase could not be produced,
 | ||||||
| 	   block all combiners taking their input from this one. | 	   block all combiners taking their input from this one. | ||||||
| 	*/ | 	*/ | ||||||
| 	register trf* phase; | 	register trf* phase; | ||||||
| 	for ( phase=first ; phase ; phase=phase->t_next ) { | 	for (phase = first; phase; phase = phase->t_next) | ||||||
| 		if ( phase->t_combine ) phase->t_blocked=YES ; | 	{ | ||||||
|  | 		if (phase->t_combine) | ||||||
|  | 			phase->t_blocked = YES; | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| static int mayprep(void) { | static int mayprep(void) | ||||||
|  | { | ||||||
| 	int file; | 	int file; | ||||||
| 	char fc; | 	char fc; | ||||||
| 	file = open(in.p_path, 0); | 	file = open(in.p_path, 0); | ||||||
| 	if ( file<0 ) return 0 ; | 	if (file < 0) | ||||||
| 	if ( read(file,&fc,1)!=1 ) fc=0 ; | 		return 0; | ||||||
|  | 	if (read(file, &fc, 1) != 1) | ||||||
|  | 		fc = 0; | ||||||
| 	close(file); | 	close(file); | ||||||
| 	return fc == '#'; | 	return fc == '#'; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| static void scanneeds(void) { | static void scanneeds(void) | ||||||
|  | { | ||||||
| 	register list_elem* elem; | 	register list_elem* elem; | ||||||
| 	scanlist(l_first(head_list), elem) { setneeds(l_content(*elem), 0); } | 	scanlist(l_first(head_list), elem) { setneeds(l_content(*elem), 0); } | ||||||
| 	l_clear(&head_list); | 	l_clear(&head_list); | ||||||
|  | @ -435,14 +552,18 @@ static void scanneeds(void) { | ||||||
| 	l_clear(&tail_list); | 	l_clear(&tail_list); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| static void setneeds(const char *suffix, int tail) { | static void setneeds(const char* suffix, int tail) | ||||||
|  | { | ||||||
| 	trf* phase; | 	trf* phase; | ||||||
| 
 | 
 | ||||||
| 	p_suffix = suffix; | 	p_suffix = suffix; | ||||||
| 	switch ( getpath(&phase) ) { | 	switch (getpath(&phase)) | ||||||
|  | 	{ | ||||||
| 		case F_OK: | 		case F_OK: | ||||||
| 		for ( ; phase ; phase= phase->t_next ) { | 			for (; phase; phase = phase->t_next) | ||||||
| 			if ( phase->t_needed ) { | 			{ | ||||||
|  | 				if (phase->t_needed) | ||||||
|  | 				{ | ||||||
| 					if (tail) | 					if (tail) | ||||||
| 						add_tail(phase->t_needed); | 						add_tail(phase->t_needed); | ||||||
| 					else | 					else | ||||||
|  | @ -460,6 +581,7 @@ static void setneeds(const char *suffix, int tail) { | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| static void noodstop(int sig) { | static void noodstop(int sig) | ||||||
|  | { | ||||||
| 	quit(-3); | 	quit(-3); | ||||||
| } | } | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		
		Reference in a new issue