summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenis Vlasenko2006-12-18 22:32:45 +0000
committerDenis Vlasenko2006-12-18 22:32:45 +0000
commit7cfecc4b36c5bd6e1e85fe8851ebd90fe1edb8f4 (patch)
tree2d03681bc35891414026aa56eeed0fbc29530124
parentc8e6e35ba4095846121d5b5a3eee57caa5e8e0fb (diff)
downloadbusybox-7cfecc4b36c5bd6e1e85fe8851ebd90fe1edb8f4.zip
busybox-7cfecc4b36c5bd6e1e85fe8851ebd90fe1edb8f4.tar.gz
xfuncs.c: dietlibc actually HAS fdprintf!
platform.h: define strchrnul for dietlibc ash: stop using few non-standard functions
-rw-r--r--include/platform.h13
-rw-r--r--libbb/xfuncs.c4
-rw-r--r--shell/ash.c20
3 files changed, 24 insertions, 13 deletions
diff --git a/include/platform.h b/include/platform.h
index 860143f..1cc9782 100644
--- a/include/platform.h
+++ b/include/platform.h
@@ -193,9 +193,18 @@ typedef unsigned long long int uintmax_t;
/* Platforms that haven't got dprintf need to implement fdprintf() in
* libbb. This would require a platform.c. It's not going to be cleaned
* out of the tree, so stop saying it should be. */
+#if !defined(__dietlibc__)
+/* Needed for: glibc */
+/* Not needed for: dietlibc */
+/* Others: ?? (add as needed) */
#define fdprintf dprintf
-#ifdef __dietlibc__
-int dprintf(int fd, const char *format, ...);
+#endif
+
+#if defined(__dietlibc__)
+static ATTRIBUTE_ALWAYS_INLINE char* strchrnul(const char *s, char c) {
+ while (*s && *s != c) ++s;
+ return (char*)s;
+}
#endif
/* Don't use lchown with glibc older than 2.1.x ... uC-libc lacks it */
diff --git a/libbb/xfuncs.c b/libbb/xfuncs.c
index 4790aa1..9efccc5 100644
--- a/libbb/xfuncs.c
+++ b/libbb/xfuncs.c
@@ -411,8 +411,8 @@ char *xasprintf(const char *format, ...)
return string_ptr;
}
-#ifdef __dietlibc__
-int dprintf(int fd, const char *format, ...)
+#if 0 /* If we will ever meet a libc which hasn't [f]dprintf... */
+int fdprintf(int fd, const char *format, ...)
{
va_list p;
int r;
diff --git a/shell/ash.c b/shell/ash.c
index 2f7cc86..ae5182a 100644
--- a/shell/ash.c
+++ b/shell/ash.c
@@ -5851,7 +5851,7 @@ _rmescapes(char *str, int flag)
}
q = r;
if (len > 0) {
- q = mempcpy(q, str, len);
+ q = memcpy(q, str, len) + len;
}
}
inquotes = (flag & RMESCAPE_QUOTED) ^ RMESCAPE_QUOTED;
@@ -8433,7 +8433,7 @@ char *
stnputs(const char *s, size_t n, char *p)
{
p = makestrspace(n, p);
- p = mempcpy(p, s, n);
+ p = memcpy(p, s, n) + n;
return p;
}
@@ -8517,7 +8517,7 @@ single_quote(const char *s) {
q = p = makestrspace(len + 3, p);
*q++ = '\'';
- q = mempcpy(q, s, len);
+ q = memcpy(q, s, len) + len;
*q++ = '\'';
s += len;
@@ -8530,7 +8530,7 @@ single_quote(const char *s) {
q = p = makestrspace(len + 3, p);
*q++ = '"';
- q = mempcpy(q, s, len);
+ q = memcpy(q, s, len) + len;
*q++ = '"';
s += len;
@@ -8754,11 +8754,12 @@ copynodelist(struct nodelist *lp)
static char *
-nodesavestr(char *s)
+nodesavestr(char *s)
{
- char *rtn = funcstring;
+ char *rtn = funcstring;
- funcstring = stpcpy(funcstring, s) + 1;
+ strcpy(funcstring, s);
+ funcstring += strlen(s) + 1;
return rtn;
}
@@ -12013,10 +12014,11 @@ setvar(const char *name, const char *val, int flags)
vallen = strlen(val);
}
INTOFF;
- p = mempcpy(nameeq = ckmalloc(namelen + vallen + 2), name, namelen);
+ nameeq = ckmalloc(namelen + vallen + 2)
+ p = memcpy(nameeq, name, namelen) + namelen;
if (val) {
*p++ = '=';
- p = mempcpy(p, val, vallen);
+ p = memcpy(p, val, vallen) + vallen;
}
*p = '\0';
setvareq(nameeq, flags | VNOSAVE);