summaryrefslogtreecommitdiff
path: root/lib/sh
diff options
context:
space:
mode:
authorChet Ramey <chet.ramey@case.edu>2013-08-12 19:18:42 -0400
committerChet Ramey <chet.ramey@case.edu>2013-08-12 19:18:42 -0400
commit1442f67c408e60769ff344f9e4c05104e2cef7d0 (patch)
tree6c093574f9b9342f172a8d8367aa9a5849cd4d85 /lib/sh
parent25eee30b53c60c43b155880820d29c84928847ca (diff)
downloadbash-4.3-beta.tar.gz
bash-4.3-beta overlaybash-4.3-beta
Diffstat (limited to 'lib/sh')
-rw-r--r--lib/sh/casemod.c17
-rw-r--r--lib/sh/pathphys.c2
-rw-r--r--lib/sh/shquote.c9
3 files changed, 25 insertions, 3 deletions
diff --git a/lib/sh/casemod.c b/lib/sh/casemod.c
index 5edc08aa..bbcffa6f 100644
--- a/lib/sh/casemod.c
+++ b/lib/sh/casemod.c
@@ -39,6 +39,7 @@
#include <shmbchar.h>
#include <shmbutil.h>
#include <chartypes.h>
+#include <typemax.h>
#include <glob/strmatch.h>
@@ -68,6 +69,10 @@
extern char *substring __P((char *, int, int));
+#ifndef UCHAR_MAX
+# define UCHAR_MAX TYPE_MAXIMUM(unsigned char)
+#endif
+
#if defined (HANDLE_MULTIBYTE)
static wchar_t
cval (s, i)
@@ -141,8 +146,10 @@ sh_modcase (string, pat, flags)
if (iswalnum (wc) == 0)
{
inword = 0;
+#if 0
ADVANCE_CHAR (ret, end, start);
continue;
+#endif
}
if (pat)
@@ -203,8 +210,11 @@ sh_modcase (string, pat, flags)
else
nop = flags;
- if (MB_CUR_MAX == 1 || is_basic ((int)wc))
+ /* Need to check UCHAR_MAX since wc may have already been converted to a
+ wide character by cval() */
+ if (MB_CUR_MAX == 1 || (wc <= UCHAR_MAX && is_basic ((int)wc)))
{
+singlebyte:
switch (nop)
{
default:
@@ -221,7 +231,10 @@ sh_modcase (string, pat, flags)
{
m = mbrtowc (&wc, string + start, end - start, &state);
if (MB_INVALIDCH (m))
- wc = (wchar_t)string[start];
+ {
+ wc = (unsigned char)string[start];
+ goto singlebyte;
+ }
else if (MB_NULLWCH (m))
wc = L'\0';
switch (nop)
diff --git a/lib/sh/pathphys.c b/lib/sh/pathphys.c
index cddca483..26016b76 100644
--- a/lib/sh/pathphys.c
+++ b/lib/sh/pathphys.c
@@ -269,7 +269,7 @@ sh_realpath (pathname, resolved)
wd = get_working_directory ("sh_realpath");
if (wd == 0)
return ((char *)NULL);
- tdir = sh_makepath ((char *)pathname, wd, 0);
+ tdir = sh_makepath (wd, (char *)pathname, 0);
free (wd);
}
else
diff --git a/lib/sh/shquote.c b/lib/sh/shquote.c
index c79ba9cd..31cce1c1 100644
--- a/lib/sh/shquote.c
+++ b/lib/sh/shquote.c
@@ -94,6 +94,15 @@ sh_single_quote (string)
result = (char *)xmalloc (3 + (4 * strlen (string)));
r = result;
+
+ if (string[0] == '\'' && string[1] == 0)
+ {
+ *r++ = '\\';
+ *r++ = '\'';
+ *r++ = 0;
+ return result;
+ }
+
*r++ = '\'';
for (s = string; s && (c = *s); s++)