diff options
author | Anthony G. Basile <blueness@gentoo.org> | 2013-08-02 20:46:21 -0400 |
---|---|---|
committer | Anthony G. Basile <blueness@gentoo.org> | 2013-08-02 20:46:21 -0400 |
commit | a3cd924ecba40190703919285f5e2ef559d32ccd (patch) | |
tree | 344f2193c6d74d41bd6d34e828434350c4304d78 /src/libudev/util.c | |
parent | a57c8bba0d0c81cd3f884e173ff56f25b5946cf1 (diff) |
src/libudev/{strv,util}.{h,c}: reorder functions
We reorder the functions prototypes and definitions to match
upstream as in commit aa417a4d83999f6d7f092161d5c411b8cbce9977.
The order was lost when that commit was revert and the functions
re-introduced in later commits.
Preserving the order helps to better track upstream changes when
doing a diff between files.
Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
Diffstat (limited to 'src/libudev/util.c')
-rw-r--r-- | src/libudev/util.c | 70 |
1 files changed, 35 insertions, 35 deletions
diff --git a/src/libudev/util.c b/src/libudev/util.c index 5abf6589af..10a786368e 100644 --- a/src/libudev/util.c +++ b/src/libudev/util.c @@ -545,6 +545,41 @@ char *strappend(const char *s, const char *suffix) { return strnappend(s, suffix, suffix ? strlen(suffix) : 0); } +char hexchar(int x) { + static const char table[16] = "0123456789abcdef"; + + return table[x & 15]; +} + +char *xescape(const char *s, const char *bad) { + char *r, *t; + const char *f; + + /* Escapes all chars in bad, in addition to \ and all special + * chars, in \xFF style escaping. May be reversed with + * cunescape. */ + + r = new(char, strlen(s) * 4 + 1); + if (!r) + return NULL; + + for (f = s, t = r; *f; f++) { + + if ((*f < ' ') || (*f >= 127) || + (*f == '\\') || strchr(bad, *f)) { + *(t++) = '\\'; + *(t++) = 'x'; + *(t++) = hexchar(*f >> 4); + *(t++) = hexchar(*f); + } else + *(t++) = *f; + } + + *t = 0; + + return r; +} + _pure_ static bool ignore_file_allow_backup(const char *filename) { assert(filename); @@ -999,12 +1034,6 @@ int fd_inc_sndbuf(int fd, size_t n) { return 1; } -char hexchar(int x) { - static const char table[16] = "0123456789abcdef"; - - return table[x & 15]; -} - bool in_initrd(void) { static __thread int saved = -1; struct statfs s; @@ -1051,32 +1080,3 @@ void *xbsearch_r(const void *key, const void *base, size_t nmemb, size_t size, } return NULL; } - -char *xescape(const char *s, const char *bad) { - char *r, *t; - const char *f; - - /* Escapes all chars in bad, in addition to \ and all special - * chars, in \xFF style escaping. May be reversed with - * cunescape. */ - - if (!(r = new(char, strlen(s)*4+1))) - return NULL; - - for (f = s, t = r; *f; f++) { - - if (*f < ' ' || *f >= 127 || - *f == '\\' || strchr(bad, *f)) { - *(t++) = '\\'; - *(t++) = 'x'; - *(t++) = hexchar(*f >> 4); - *(t++) = hexchar(*f); - } else - *(t++) = *f; - } - - *t = 0; - - return r; -} - |