chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Prep v234: Apply missing upstream fixes in src/basic (1/6)
[elogind.git]
/
src
/
basic
/
string-util.c
diff --git
a/src/basic/string-util.c
b/src/basic/string-util.c
index 5d4510e1b3bc457103da44e9128cc240588fdc53..9b060a9a20dbb181f715bf348c741275dff0e209 100644
(file)
--- a/
src/basic/string-util.c
+++ b/
src/basic/string-util.c
@@
-218,7
+218,7
@@
char *strappend(const char *s, const char *suffix) {
return strnappend(s, suffix, suffix ? strlen(suffix) : 0);
}
return strnappend(s, suffix, suffix ? strlen(suffix) : 0);
}
-char *strjoin(const char *x, ...) {
+char *strjoin
_real
(const char *x, ...) {
va_list ap;
size_t l;
char *r, *p;
va_list ap;
size_t l;
char *r, *p;
@@
-292,6
+292,7
@@
char *strstrip(char *s) {
return s;
}
return s;
}
+#if 0 /// UNNEEDED by elogind
char *delete_chars(char *s, const char *bad) {
char *f, *t;
char *delete_chars(char *s, const char *bad) {
char *f, *t;
@@
-308,6
+309,7
@@
char *delete_chars(char *s, const char *bad) {
return s;
}
return s;
}
+#endif // 0
char *truncate_nl(char *s) {
assert(s);
char *truncate_nl(char *s) {
assert(s);
@@
-316,6
+318,7
@@
char *truncate_nl(char *s) {
return s;
}
return s;
}
+#if 0 /// UNNEEDED by elogind
char ascii_tolower(char x) {
if (x >= 'A' && x <= 'Z')
char ascii_tolower(char x) {
if (x >= 'A' && x <= 'Z')
@@
-406,6
+409,7
@@
bool chars_intersect(const char *a, const char *b) {
return false;
}
return false;
}
+#endif // 0
bool string_has_cc(const char *p, const char *ok) {
const char *t;
bool string_has_cc(const char *p, const char *ok) {
const char *t;
@@
-443,7
+447,7
@@
static char *ascii_ellipsize_mem(const char *s, size_t old_length, size_t new_le
if (old_length <= 3 || old_length <= new_length)
return strndup(s, old_length);
if (old_length <= 3 || old_length <= new_length)
return strndup(s, old_length);
- r = new0(char, new_length+
1
);
+ r = new0(char, new_length+
3
);
if (!r)
return NULL;
if (!r)
return NULL;
@@
-453,12
+457,12
@@
static char *ascii_ellipsize_mem(const char *s, size_t old_length, size_t new_le
x = new_length - 3;
memcpy(r, s, x);
x = new_length - 3;
memcpy(r, s, x);
- r[x] =
'.';
- r[x+1] =
'.'
;
- r[x+2] =
'.'
;
+ r[x] =
0xe2; /* tri-dot ellipsis: … */
+ r[x+1] =
0x80
;
+ r[x+2] =
0xa6
;
memcpy(r + x + 3,
memcpy(r + x + 3,
- s + old_length - (new_length - x -
3
),
- new_length - x -
3
);
+ s + old_length - (new_length - x -
1
),
+ new_length - x -
1
);
return r;
}
return r;
}
@@
-610,8
+614,7
@@
char *strreplace(const char *text, const char *old_string, const char *new_strin
return r;
oom:
return r;
oom:
- free(r);
- return NULL;
+ return mfree(r);
}
char *strip_tab_ansi(char **ibuf, size_t *_isz) {
}
char *strip_tab_ansi(char **ibuf, size_t *_isz) {
@@
-682,8
+685,7
@@
char *strip_tab_ansi(char **ibuf, size_t *_isz) {
if (ferror(f)) {
fclose(f);
if (ferror(f)) {
fclose(f);
- free(obuf);
- return NULL;
+ return mfree(obuf);
}
fclose(f);
}
fclose(f);
@@
-823,6
+825,7
@@
int free_and_strdup(char **p, const char *s) {
return 1;
}
return 1;
}
+#if !HAVE_DECL_EXPLICIT_BZERO
/*
* Pointer to memset is volatile so that compiler must de-reference
* the pointer and can't assume that it points to any function in
/*
* Pointer to memset is volatile so that compiler must de-reference
* the pointer and can't assume that it points to any function in
@@
-833,19
+836,19
@@
typedef void *(*memset_t)(void *,int,size_t);
static volatile memset_t memset_func = memset;
static volatile memset_t memset_func = memset;
-void
* memory_erase
(void *p, size_t l) {
-
return memset_func(p, 'x
', l);
+void
explicit_bzero
(void *p, size_t l) {
+
memset_func(p, '\0
', l);
}
}
+#endif
char* string_erase(char *x) {
char* string_erase(char *x) {
-
if (!x)
return NULL;
/* A delicious drop of snake-oil! To be called on memory where
* we stored passphrases or so, after we used them. */
if (!x)
return NULL;
/* A delicious drop of snake-oil! To be called on memory where
* we stored passphrases or so, after we used them. */
-
- return
memory_erase(x, strlen(x))
;
+ explicit_bzero(x, strlen(x));
+ return
x
;
}
char *string_free_erase(char *s) {
}
char *string_free_erase(char *s) {