the -U option did not work properly; call do_undef() now
This commit is contained in:
		
							parent
							
								
									52f08181a6
								
							
						
					
					
						commit
						64e9d11570
					
				
					 4 changed files with 19 additions and 27 deletions
				
			
		| 
						 | 
					@ -123,7 +123,7 @@ domacro()
 | 
				
			||||||
			do_pragma();
 | 
								do_pragma();
 | 
				
			||||||
			break;
 | 
								break;
 | 
				
			||||||
		case K_UNDEF:				/* "undef"	*/
 | 
							case K_UNDEF:				/* "undef"	*/
 | 
				
			||||||
			do_undef();
 | 
								do_undef((struct idf *) 0);
 | 
				
			||||||
			break;
 | 
								break;
 | 
				
			||||||
		default:
 | 
							default:
 | 
				
			||||||
			/* invalid word seen after the '#'	*/
 | 
								/* invalid word seen after the '#'	*/
 | 
				
			||||||
| 
						 | 
					@ -422,12 +422,14 @@ do_ifdef(how)
 | 
				
			||||||
		SkipToNewLine();
 | 
							SkipToNewLine();
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
do_undef()
 | 
					/* argidf != NULL when the undef came from a -U option */
 | 
				
			||||||
 | 
					do_undef(argidf)
 | 
				
			||||||
 | 
						struct idf *argidf;
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	register struct idf *id;
 | 
						register struct idf *id = argidf;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/* Forget a macro definition.	*/
 | 
						/* Forget a macro definition.	*/
 | 
				
			||||||
	if (id = GetIdentifier(1)) {
 | 
						if (id || (id = GetIdentifier(1))) {
 | 
				
			||||||
		if (id->id_macro) { /* forget the macro */
 | 
							if (id->id_macro) { /* forget the macro */
 | 
				
			||||||
			if (id->id_macro->mc_flag & NOUNDEF) {
 | 
								if (id->id_macro->mc_flag & NOUNDEF) {
 | 
				
			||||||
				lexerror("it is not allowed to undef %s", id->id_text);
 | 
									lexerror("it is not allowed to undef %s", id->id_text);
 | 
				
			||||||
| 
						 | 
					@ -437,7 +439,7 @@ do_undef()
 | 
				
			||||||
				id->id_macro = (struct macro *) 0;
 | 
									id->id_macro = (struct macro *) 0;
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
		} /* else: don't complain */
 | 
							} /* else: don't complain */
 | 
				
			||||||
		SkipToNewLine();
 | 
							if (!argidf) SkipToNewLine();
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	else
 | 
						else
 | 
				
			||||||
		lexerror("illegal #undef construction");
 | 
							lexerror("illegal #undef construction");
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -224,14 +224,7 @@ deleted, is now a debug-flag
 | 
				
			||||||
		
 | 
							
 | 
				
			||||||
	case 'U' :	{	/* -Uname :	undefine predefined	*/
 | 
						case 'U' :	{	/* -Uname :	undefine predefined	*/
 | 
				
			||||||
#ifndef NOPP
 | 
					#ifndef NOPP
 | 
				
			||||||
		register struct idf *idef;
 | 
							if (*text) do_undef(str2idf(text));
 | 
				
			||||||
 | 
					 | 
				
			||||||
		if (*text)	{
 | 
					 | 
				
			||||||
			if ((idef = str2idf(text))->id_macro) {
 | 
					 | 
				
			||||||
				free_macro(idef->id_macro);
 | 
					 | 
				
			||||||
				idef->id_macro = (struct macro *) 0;
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
#else NOPP
 | 
					#else NOPP
 | 
				
			||||||
		warning("-U option ignored");
 | 
							warning("-U option ignored");
 | 
				
			||||||
#endif NOPP
 | 
					#endif NOPP
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -133,7 +133,7 @@ domacro()
 | 
				
			||||||
			do_pragma();
 | 
								do_pragma();
 | 
				
			||||||
			break;
 | 
								break;
 | 
				
			||||||
		case K_UNDEF:				/* "undef"	*/
 | 
							case K_UNDEF:				/* "undef"	*/
 | 
				
			||||||
			do_undef();
 | 
								do_undef((char *)0);
 | 
				
			||||||
			break;
 | 
								break;
 | 
				
			||||||
		default:
 | 
							default:
 | 
				
			||||||
			/* invalid word seen after the '#'	*/
 | 
								/* invalid word seen after the '#'	*/
 | 
				
			||||||
| 
						 | 
					@ -439,13 +439,15 @@ do_ifdef(how)
 | 
				
			||||||
		SkipToNewLine();
 | 
							SkipToNewLine();
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
do_undef()
 | 
					/* argstr != NULL when the undef came from a -U option */
 | 
				
			||||||
 | 
					do_undef(argstr)
 | 
				
			||||||
 | 
						char *argstr;
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	register struct idf *id;
 | 
						register struct idf *id;
 | 
				
			||||||
	register char *str;
 | 
						register char *str = argstr;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/* Forget a macro definition.	*/
 | 
						/* Forget a macro definition.	*/
 | 
				
			||||||
	if (str = GetIdentifier(1)) {
 | 
						if (str || (str = GetIdentifier(1))) {
 | 
				
			||||||
		if ((id = findidf(str)) && id->id_macro) {
 | 
							if ((id = findidf(str)) && id->id_macro) {
 | 
				
			||||||
			if (id->id_macro->mc_flag & NOUNDEF) {
 | 
								if (id->id_macro->mc_flag & NOUNDEF) {
 | 
				
			||||||
				error("it is not allowed to #undef %s", str);
 | 
									error("it is not allowed to #undef %s", str);
 | 
				
			||||||
| 
						 | 
					@ -455,9 +457,11 @@ do_undef()
 | 
				
			||||||
				id->id_macro = (struct macro *) 0;
 | 
									id->id_macro = (struct macro *) 0;
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
		} /* else: don't complain */
 | 
							} /* else: don't complain */
 | 
				
			||||||
 | 
							if (!argstr){
 | 
				
			||||||
			free(str);
 | 
								free(str);
 | 
				
			||||||
			SkipToNewLine();
 | 
								SkipToNewLine();
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
	else
 | 
						else
 | 
				
			||||||
		error("illegal #undef construction");
 | 
							error("illegal #undef construction");
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -109,14 +109,7 @@ do_option(text)
 | 
				
			||||||
		options['P'] = 1;
 | 
							options['P'] = 1;
 | 
				
			||||||
		break;
 | 
							break;
 | 
				
			||||||
	case 'U' :	/* -Uname :	undefine predefined	*/
 | 
						case 'U' :	/* -Uname :	undefine predefined	*/
 | 
				
			||||||
		if (*text)	{
 | 
							if (*text) do_undef(text);
 | 
				
			||||||
			register struct idf *idef = findidf(text);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
			if (idef && idef->id_macro) {
 | 
					 | 
				
			||||||
				free_macro(idef->id_macro);
 | 
					 | 
				
			||||||
				idef->id_macro = (struct macro *) 0;
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
		break;
 | 
							break;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		
		Reference in a new issue