| Only in bash-4.3.30: build |
| diff -ur bash-4.3.30.dist/builtins/echo.def bash-4.3.30/builtins/echo.def |
| --- bash-4.3.30.dist/builtins/echo.def 2011-06-29 09:55:58.000000000 -0400 |
| +++ bash-4.3.30/builtins/echo.def 2016-06-03 17:40:57.834915855 -0400 |
| @@ -108,8 +108,9 @@ |
| echo_builtin (list) |
| WORD_LIST *list; |
| { |
| - int display_return, do_v9, i, len; |
| - char *temp, *s; |
| + int display_return, do_v9, i, j, len, malloc_len; |
| + char *temp, *s, *m; |
| + WORD_LIST *save_list; |
| |
| do_v9 = xpg_echo; |
| display_return = 1; |
| @@ -162,6 +163,30 @@ |
| clearerr (stdout); /* clear error before writing and testing success */ |
| |
| terminate_immediately++; |
| + malloc_len = 0; |
| + m = NULL; |
| + save_list = list; |
| + while (list) |
| + { |
| + i = len = 0; |
| + temp = do_v9 ? ansicstr (list->word->word, STRLEN (list->word->word), 1, &i, &len) |
| + : list->word->word; |
| + if (!temp) |
| + continue; |
| + malloc_len += do_v9 ? len : strlen(temp); |
| + if (do_v9) |
| + free (temp); |
| + list = list->next; |
| + if (list) |
| + malloc_len++; |
| + } |
| + if (display_return) |
| + malloc_len++; |
| + m = malloc(malloc_len); |
| + if (m == NULL) |
| + fatal_error ("echo: could not allocate %lu bytes", (unsigned long)malloc_len); |
| + list = save_list; |
| + j = 0; |
| while (list) |
| { |
| i = len = 0; |
| @@ -169,19 +194,13 @@ |
| : list->word->word; |
| if (temp) |
| { |
| - if (do_v9) |
| - { |
| - for (s = temp; len > 0; len--) |
| - putchar (*s++); |
| - } |
| - else |
| - printf ("%s", temp); |
| -#if defined (SunOS5) |
| - fflush (stdout); /* Fix for bug in SunOS 5.5 printf(3) */ |
| -#endif |
| + if (!do_v9) |
| + len = strlen(temp); |
| + memmove(m + j, temp, len); |
| + j += len; |
| + if (do_v9) |
| + free (temp); |
| } |
| - if (do_v9 && temp) |
| - free (temp); |
| list = list->next; |
| if (i) |
| { |
| @@ -189,11 +208,15 @@ |
| break; |
| } |
| if (list) |
| - putchar(' '); |
| + m[j++] = ' '; |
| } |
| - |
| if (display_return) |
| - putchar ('\n'); |
| + m[j++] = '\n'; |
| + write(STDOUT_FILENO, m, j); |
| + free(m); |
| +#if defined (SunOS5) |
| + fflush (stdout); /* Fix for bug in SunOS 5.5 printf(3) */ |
| +#endif |
| |
| terminate_immediately--; |
| return (sh_chkwrite (EXECUTION_SUCCESS)); |
| diff -ur bash-4.3.30.dist/configure bash-4.3.30/configure |
| --- bash-4.3.30.dist/configure 2014-02-11 10:38:00.000000000 -0500 |
| +++ bash-4.3.30/configure 2016-05-16 23:04:59.481616025 -0400 |
| @@ -2853,6 +2853,7 @@ |
| sparc-linux*) opt_bash_malloc=no ;; # sparc running linux; requires ELF |
| #*-freebsd*-gnu) opt_bash_malloc=no ;; # there's some undetermined problem here |
| #*-freebsd*) opt_bash_malloc=no ;; # they claim it's better; I disagree |
| +*-akaros*) opt_bash_malloc=no ;; # they claim it needs eight-bit alignment |
| *-openbsd*) opt_bash_malloc=no ;; # they claim it needs eight-bit alignment |
| *-mirbsd*) opt_bash_malloc=no ;; # they claim it needs eight-bit alignment |
| *-aix*) opt_bash_malloc=no ;; # AIX machines |
| diff -ur bash-4.3.30.dist/error.c bash-4.3.30/error.c |
| --- bash-4.3.30.dist/error.c 2014-01-17 08:09:33.000000000 -0500 |
| +++ bash-4.3.30/error.c 2016-05-25 13:40:26.978379551 -0400 |
| @@ -487,3 +487,32 @@ |
| { |
| report_error (_("%s: readonly variable"), s); |
| } |
| + |
| +#if defined (USE_AKAROS_STRERROR) |
| +#ifndef MAX_ERRSTR_LEN |
| +#define MAX_ERRSTR_LEN 128 |
| +#endif |
| +char * |
| +akaros_strerror(e) |
| + int e; |
| +{ |
| + static char emsg[2*MAX_ERRSTR_LEN]; |
| + char ebuf[MAX_ERRSTR_LEN]; |
| + size_t len; |
| + int serrno; |
| + char *estr, *strerror_str; |
| + |
| + serrno = errno; |
| + estr = errstr (); |
| + strerror_str = strerror_r (e, ebuf, sizeof (ebuf)); |
| + len = strlen (strerror_str); |
| + if (len > (sizeof (emsg) - 1)) |
| + len = sizeof (emsg) - 1; |
| + memmove (emsg, strerror_str, len); |
| + if (e == serrno && estr && *estr) |
| + snprintf (emsg + len, sizeof (emsg) - len, ", %s", estr); |
| + ebuf[sizeof (ebuf) - 1] = '\0'; |
| + |
| + return emsg; |
| +} |
| +#endif |
| diff -ur bash-4.3.30.dist/mksyntax.c bash-4.3.30/mksyntax.c |
| --- bash-4.3.30.dist/mksyntax.c 2012-07-29 19:48:38.000000000 -0400 |
| +++ bash-4.3.30/mksyntax.c 2016-05-25 11:59:57.560352289 -0400 |
| @@ -40,6 +40,10 @@ |
| extern int errno; |
| #endif |
| |
| +#ifdef strerror |
| +#undef strerror |
| +#endif |
| + |
| #ifndef HAVE_STRERROR |
| extern char *strerror(); |
| #endif |
| diff -ur bash-4.3.30.dist/support/config.guess bash-4.3.30/support/config.guess |
| --- bash-4.3.30.dist/support/config.guess 2013-12-16 16:02:33.000000000 -0500 |
| +++ bash-4.3.30/support/config.guess 2016-05-16 23:04:12.844336864 -0400 |
| @@ -219,6 +219,10 @@ |
| UNAME_MACHINE_ARCH=`arch | sed 's/Bitrig.//'` |
| echo ${UNAME_MACHINE_ARCH}-unknown-bitrig${UNAME_RELEASE} |
| exit ;; |
| + *:Akaros:*:*) |
| + UNAME_MACHINE_ARCH=x86_64 |
| + echo x86_64-ucb-akaros1.0 |
| + exit ;; |
| *:OpenBSD:*:*) |
| UNAME_MACHINE_ARCH=`arch | sed 's/OpenBSD.//'` |
| echo ${UNAME_MACHINE_ARCH}-unknown-openbsd${UNAME_RELEASE} |
| diff -ur bash-4.3.30.dist/support/config.sub bash-4.3.30/support/config.sub |
| --- bash-4.3.30.dist/support/config.sub 2013-12-17 10:49:47.000000000 -0500 |
| +++ bash-4.3.30/support/config.sub 2016-05-16 23:05:28.906423063 -0400 |
| @@ -1356,7 +1356,7 @@ |
| | -hpux* | -unos* | -osf* | -luna* | -dgux* | -auroraux* | -solaris* \ |
| | -sym* | -kopensolaris* | -plan9* \ |
| | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \ |
| - | -aos* | -aros* \ |
| + | -akaros* | -aos* | -aros* \ |
| | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \ |
| | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \ |
| | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \ |