return;
if (ifsfirst.endoff > endoff) {
- while (ifsfirst.next != NULL) {
+ while (ifsfirst.next) {
struct ifsregion *ifsp;
INT_OFF;
ifsp = ifsfirst.next->next;
ifsfirst.next = ifsp;
INT_ON;
}
- if (ifsfirst.begoff > endoff)
+ if (ifsfirst.begoff > endoff) {
ifslastp = NULL;
- else {
+ } else {
ifslastp = &ifsfirst;
ifsfirst.endoff = endoff;
}
ifslastp = &ifsfirst;
while (ifslastp->next && ifslastp->next->begoff < endoff)
- ifslastp=ifslastp->next;
- while (ifslastp->next != NULL) {
+ ifslastp = ifslastp->next;
+ while (ifslastp->next) {
struct ifsregion *ifsp;
INT_OFF;
ifsp = ifslastp->next->next;
if (quoted == 0)
recordregion(startloc, dest - (char *)stackblock(), 0);
- TRACE(("evalbackq: size=%d: \"%.*s\"\n",
- (dest - (char *)stackblock()) - startloc,
- (dest - (char *)stackblock()) - startloc,
+ TRACE(("evalbackq: size:%d:'%.*s'\n",
+ (int)((dest - (char *)stackblock()) - startloc),
+ (int)((dest - (char *)stackblock()) - startloc),
stackblock() + startloc));
}
}
static char *
-scanleft(char *startp, char *rmesc, char *rmescend UNUSED_PARAM, char *str, int quotes,
- int zero)
-{
-// This commented out code was added by James Simmons <jsimmons@infradead.org>
-// as part of a larger change when he added support for ${var/a/b}.
-// However, it broke # and % operators:
-//
-//var=ababcdcd
-// ok bad
-//echo ${var#ab} abcdcd abcdcd
-//echo ${var##ab} abcdcd abcdcd
-//echo ${var#a*b} abcdcd ababcdcd (!)
-//echo ${var##a*b} cdcd cdcd
-//echo ${var#?} babcdcd ababcdcd (!)
-//echo ${var##?} babcdcd babcdcd
-//echo ${var#*} ababcdcd babcdcd (!)
-//echo ${var##*}
-//echo ${var%cd} ababcd ababcd
-//echo ${var%%cd} ababcd abab (!)
-//echo ${var%c*d} ababcd ababcd
-//echo ${var%%c*d} abab ababcdcd (!)
-//echo ${var%?} ababcdc ababcdc
-//echo ${var%%?} ababcdc ababcdcd (!)
-//echo ${var%*} ababcdcd ababcdcd
-//echo ${var%%*}
-//
-// Commenting it back out helped. Remove it completely if it really
-// is not needed.
-
- char *loc, *loc2; //, *full;
+scanleft(char *startp, char *rmesc, char *rmescend UNUSED_PARAM,
+ char *pattern, int quotes, int zero)
+{
+ char *loc, *loc2;
char c;
loc = startp;
loc2 = rmesc;
do {
- int match; // = strlen(str);
+ int match;
const char *s = loc2;
c = *loc2;
*loc2 = '\0';
s = rmesc;
}
- match = pmatch(str, s); // this line was deleted
-
-// // chop off end if its '*'
-// full = strrchr(str, '*');
-// if (full && full != str)
-// match--;
-//
-// // If str starts with '*' replace with s.
-// if ((*str == '*') && strlen(s) >= match) {
-// full = xstrdup(s);
-// strncpy(full+strlen(s)-match+1, str+1, match-1);
-// } else
-// full = xstrndup(str, match);
-// match = strncmp(s, full, strlen(full));
-// free(full);
-//
+ match = pmatch(pattern, s);
+
*loc2 = c;
- if (match) // if (!match)
+ if (match)
return loc;
if (quotes && (unsigned char)*loc == CTLESC)
loc++;
loc++;
loc2++;
} while (c);
- return 0;
+ return NULL;
}
static char *
-scanright(char *startp, char *rmesc, char *rmescend, char *pattern, int quotes, int match_at_start)
+scanright(char *startp, char *rmesc, char *rmescend,
+ char *pattern, int quotes, int match_at_start)
{
#if !ENABLE_ASH_OPTIMIZE_FOR_SIZE
int try2optimize = match_at_start;
}
}
}
- return 0;
+ return NULL;
}
static void varunset(const char *, const char *, const char *, int) NORETURN;
msg = umsg;
}
}
- ash_msg_and_raise_error("%.*s: %s%s", end - var - 1, var, msg, tail);
+ ash_msg_and_raise_error("%.*s: %s%s", (int)(end - var - 1), var, msg, tail);
}
#if ENABLE_ASH_BASH_COMPAT