summaryrefslogtreecommitdiff
path: root/libbb
diff options
context:
space:
mode:
authorDenis Vlasenko2007-01-12 22:10:34 +0000
committerDenis Vlasenko2007-01-12 22:10:34 +0000
commit3a34d0c08a77ee48edc3f4353cc49b95aba85c2f (patch)
tree09708579e18a033c6722c5194c46116705f47b83 /libbb
parent21b080daa8c180a43d10d6b3dee47134ef21e581 (diff)
downloadbusybox-3a34d0c08a77ee48edc3f4353cc49b95aba85c2f.zip
busybox-3a34d0c08a77ee48edc3f4353cc49b95aba85c2f.tar.gz
random small size optimizations
Diffstat (limited to 'libbb')
-rw-r--r--libbb/messages.c1
-rw-r--r--libbb/read.c2
-rw-r--r--libbb/xfuncs.c13
3 files changed, 15 insertions, 1 deletions
diff --git a/libbb/messages.c b/libbb/messages.c
index c640faf..6c3d2f6 100644
--- a/libbb/messages.c
+++ b/libbb/messages.c
@@ -28,6 +28,7 @@ const char bb_msg_standard_input[] = "standard input";
const char bb_msg_standard_output[] = "standard output";
const char bb_str_default[] = "default";
+const char bb_hexdigits_upcase[] = "0123456789ABCDEF";
const char bb_path_passwd_file[] = "/etc/passwd";
const char bb_path_shadow_file[] = "/etc/shadow";
diff --git a/libbb/read.c b/libbb/read.c
index 50e0354..861828d 100644
--- a/libbb/read.c
+++ b/libbb/read.c
@@ -88,7 +88,7 @@ char *reads(int fd, char *buffer, size_t size)
*p++ = '\0';
// avoid incorrect (unsigned) widening
offset = (off_t)(p-buffer) - (off_t)size;
- // set fd position the right after the \n
+ // set fd position right after '\n'
if (offset && lseek(fd, offset, SEEK_CUR) == (off_t)-1)
return NULL;
}
diff --git a/libbb/xfuncs.c b/libbb/xfuncs.c
index 827cbe8..2075379 100644
--- a/libbb/xfuncs.c
+++ b/libbb/xfuncs.c
@@ -333,6 +333,19 @@ char *itoa(int n)
return local_buf;
}
+// Emit a string of hex representation of bytes
+char *bin2hex(char *p, const char *cp, int count)
+{
+ while (count) {
+ unsigned char c = *cp++;
+ /* put lowercase hex digits */
+ *p++ = 0x10 | bb_hexdigits_upcase[c >> 4];
+ *p++ = 0x10 | bb_hexdigits_upcase[c & 0xf];
+ count--;
+ }
+ return p;
+}
+
// Die with an error message if we can't set gid. (Because resource limits may
// limit this user to a given number of processes, and if that fills up the
// setgid() will fail and we'll _still_be_root_, which is bad.)