dtc: Refactor character literal parsing code

Move the parsing of hex, octal and escaped characters from data.c
to util.c where it can be used for character literal parsing within
strings as well as for stand alone C style character literals.

Signed-off-by: Anton Staaf <robotboy@chromium.org>
Acked-by: David Gibson <david@gibson.dropbear.id.au>
This commit is contained in:
Anton Staaf 2011-09-09 12:16:29 -07:00 committed by Jon Loeliger
parent ed8fee1a64
commit b43335a238
3 changed files with 110 additions and 80 deletions

8
util.h
View file

@ -64,4 +64,12 @@ extern char *join_path(const char *path, const char *name);
* @return 1 if a valid printable string, 0 if not */
int util_is_printable_string(const void *data, int len);
/*
* Parse an escaped character starting at index i in string s. The resulting
* character will be returned and the index i will be updated to point at the
* character directly after the end of the encoding, this may be the '\0'
* terminator of the string.
*/
char get_escape_char(const char *s, int *i);
#endif /* _UTIL_H */