From a3143cf4408435edb13d4e50bcb92647974fe9a3 Mon Sep 17 00:00:00 2001 From: Peter Avalos Date: Thu, 28 Sep 2006 04:19:40 +0000 Subject: [PATCH] Fix compiler warnings by creating a new macro "is_eof" that does the PEOF comparison, and don't use it if the character comes from a string. Taken from FreeBSD. --- bin/sh/mksyntax.c | 9 +++++---- bin/sh/parser.c | 9 +++++---- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/bin/sh/mksyntax.c b/bin/sh/mksyntax.c index ce3874ef73..7a4e54534f 100644 --- a/bin/sh/mksyntax.c +++ b/bin/sh/mksyntax.c @@ -36,7 +36,7 @@ * @(#) Copyright (c) 1991, 1993 The Regents of the University of California. All rights reserved. * @(#)mksyntax.c 8.2 (Berkeley) 5/4/95 * $FreeBSD: src/bin/sh/mksyntax.c,v 1.14.2.3 2002/07/19 04:38:51 tjr Exp $ - * $DragonFly: src/bin/sh/mksyntax.c,v 1.3 2004/03/19 18:39:41 cpressey Exp $ + * $DragonFly: src/bin/sh/mksyntax.c,v 1.4 2006/09/28 04:19:40 pavalos Exp $ */ /* @@ -338,9 +338,10 @@ print(const char *name) static const char *macro[] = { "#define is_digit(c)\t((is_type+SYNBASE)[c] & ISDIGIT)", - "#define is_alpha(c)\t((c) != PEOF && ((c) < CTLESC || (c) > CTLQUOTEMARK) && isalpha((unsigned char) (c)))", - "#define is_name(c)\t((c) != PEOF && ((c) < CTLESC || (c) > CTLQUOTEMARK) && ((c) == '_' || isalpha((unsigned char) (c))))", - "#define is_in_name(c)\t((c) != PEOF && ((c) < CTLESC || (c) > CTLQUOTEMARK) && ((c) == '_' || isalnum((unsigned char) (c))))", + "#define is_eof(c)\t((c) == PEOF)", + "#define is_alpha(c)\t(((c) < CTLESC || (c) > CTLQUOTEMARK) && isalpha((unsigned char) (c)))", + "#define is_name(c)\t(((c) < CTLESC || (c) > CTLQUOTEMARK) && ((c) == '_' || isalpha((unsigned char) (c))))", + "#define is_in_name(c)\t(((c) < CTLESC || (c) > CTLQUOTEMARK) && ((c) == '_' || isalnum((unsigned char) (c))))", "#define is_special(c)\t((is_type+SYNBASE)[c] & (ISSPECL|ISDIGIT))", NULL }; diff --git a/bin/sh/parser.c b/bin/sh/parser.c index 345c816c1a..d263cb1ae6 100644 --- a/bin/sh/parser.c +++ b/bin/sh/parser.c @@ -35,7 +35,7 @@ * * @(#)parser.c 8.7 (Berkeley) 5/16/95 * $FreeBSD: src/bin/sh/parser.c,v 1.29.2.9 2002/10/18 11:24:04 tjr Exp $ - * $DragonFly: src/bin/sh/parser.c,v 1.6 2005/11/06 11:44:02 swildner Exp $ + * $DragonFly: src/bin/sh/parser.c,v 1.7 2006/09/28 04:19:40 pavalos Exp $ */ #include @@ -1189,7 +1189,8 @@ parsesub: { int bracketed_name = 0; /* used to handle ${[0-9]*} variables */ c = pgetc(); - if (c != '(' && c != '{' && !is_name(c) && !is_special(c)) { + if (c != '(' && c != '{' && (is_eof(c) || !is_name(c)) && + !is_special(c)) { USTPUTC('$', out); pungetc(); } else if (c == '(') { /* $(command) or $((arith)) */ @@ -1216,11 +1217,11 @@ parsesub: { else subtype = 0; } - if (is_name(c)) { + if (!is_eof(c) && is_name(c)) { do { STPUTC(c, out); c = pgetc(); - } while (is_in_name(c)); + } while (!is_eof(c) && is_in_name(c)); } else if (is_digit(c)) { if (bracketed_name) { do { -- 2.11.4.GIT