aboutsummaryrefslogtreecommitdiff
path: root/libbb
diff options
context:
space:
mode:
authorRon Yorston <rmy@pobox.com>2012-04-29 16:07:41 +0100
committerRon Yorston <rmy@pobox.com>2012-04-29 16:07:41 +0100
commit1129137ac4ad59034828f00456eed72dc5b6c8e6 (patch)
tree411cdb3787513e79aa5bcbfa2cb5c8fdc000be0a /libbb
parentfd571d9c7525247c0cdcf154f547d4658df0837e (diff)
parentd133144d41c2fef883d28497acafe59b6bc6043b (diff)
downloadbusybox-w32-1129137ac4ad59034828f00456eed72dc5b6c8e6.tar.gz
busybox-w32-1129137ac4ad59034828f00456eed72dc5b6c8e6.tar.bz2
busybox-w32-1129137ac4ad59034828f00456eed72dc5b6c8e6.zip
Merge branch 'busybox' into merge
Diffstat (limited to 'libbb')
-rw-r--r--libbb/lineedit.c6
-rw-r--r--libbb/safe_gethostname.c22
2 files changed, 2 insertions, 26 deletions
diff --git a/libbb/lineedit.c b/libbb/lineedit.c
index b3ae21510..ec0997037 100644
--- a/libbb/lineedit.c
+++ b/libbb/lineedit.c
@@ -1366,8 +1366,7 @@ static void load_history(line_input_t *st_parm)
1366 /* fill temp_h[], retaining only last MAX_HISTORY lines */ 1366 /* fill temp_h[], retaining only last MAX_HISTORY lines */
1367 memset(temp_h, 0, sizeof(temp_h)); 1367 memset(temp_h, 0, sizeof(temp_h));
1368 idx = 0; 1368 idx = 0;
1369 if (!ENABLE_FEATURE_EDITING_SAVE_ON_EXIT) 1369 st_parm->cnt_history_in_file = 0;
1370 st_parm->cnt_history_in_file = 0;
1371 while ((line = xmalloc_fgetline(fp)) != NULL) { 1370 while ((line = xmalloc_fgetline(fp)) != NULL) {
1372 if (line[0] == '\0') { 1371 if (line[0] == '\0') {
1373 free(line); 1372 free(line);
@@ -1375,8 +1374,7 @@ static void load_history(line_input_t *st_parm)
1375 } 1374 }
1376 free(temp_h[idx]); 1375 free(temp_h[idx]);
1377 temp_h[idx] = line; 1376 temp_h[idx] = line;
1378 if (!ENABLE_FEATURE_EDITING_SAVE_ON_EXIT) 1377 st_parm->cnt_history_in_file++;
1379 st_parm->cnt_history_in_file++;
1380 idx++; 1378 idx++;
1381 if (idx == st_parm->max_history) 1379 if (idx == st_parm->max_history)
1382 idx = 0; 1380 idx = 0;
diff --git a/libbb/safe_gethostname.c b/libbb/safe_gethostname.c
index bdb989631..cac99ae03 100644
--- a/libbb/safe_gethostname.c
+++ b/libbb/safe_gethostname.c
@@ -50,25 +50,3 @@ char* FAST_FUNC safe_gethostname(void)
50 uname(&uts); 50 uname(&uts);
51 return xstrndup(!uts.nodename[0] ? "?" : uts.nodename, sizeof(uts.nodename)); 51 return xstrndup(!uts.nodename[0] ? "?" : uts.nodename, sizeof(uts.nodename));
52} 52}
53
54/*
55 * On success return the current malloced and NUL terminated domainname.
56 * On error return malloced and NUL terminated string "?".
57 * This is an illegal first character for a domainname.
58 * The returned malloced string must be freed by the caller.
59 */
60char* FAST_FUNC safe_getdomainname(void)
61{
62#if defined(__linux__)
63/* The field domainname of struct utsname is Linux specific. */
64 struct utsname uts;
65 uname(&uts);
66 return xstrndup(!uts.domainname[0] ? "?" : uts.domainname, sizeof(uts.domainname));
67#else
68 /* We really don't care about people with domain names wider than most screens */
69 char buf[256];
70 int r = getdomainname(buf, sizeof(buf));
71 buf[sizeof(buf)-1] = '\0';
72 return xstrdup(r < 0 ? "?" : buf);
73#endif
74}