diff options
| author | 2011-02-28 08:18:35 +0000 | |
|---|---|---|
| committer | 2011-02-28 08:18:35 +0000 | |
| commit | beb05ca537de127b42bef535ffa2d30596013c87 (patch) | |
| tree | 95b8a4fde3cda8ecb93cb26be7fab699a6694f5e | |
| parent | b7aa7df5617aa3a82aeae7ea036b45b76d063c17 (diff) | |
Enable CRC(1) SHA1(1)-style hashes to work without error.
| -rw-r--r-- | src/emu/hash.c | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/src/emu/hash.c b/src/emu/hash.c index ad2322cf1c2..8b47a206a5c 100644 --- a/src/emu/hash.c +++ b/src/emu/hash.c @@ -199,12 +199,22 @@ const char *hash_base::string(astring &buffer) bool hash_base::from_string(const char *&string, int length) { + // reset the error and our buffer + m_parse_error = false; + memset(m_bufptr, 0, m_length); + + // special case for idiom HASH(1) to map to a dummy (0) hash + if (string[0] == '1' && fromhex(string[1]) == -1) + { + string++; + return true; + } + // fail if we're too short if (length < 2 * m_length) return false; // loop over bytes - m_parse_error = false; for (int index = 0; index < m_length; index++) { // parse the upper digit @@ -212,7 +222,6 @@ bool hash_base::from_string(const char *&string, int length) if (upper == -1) { m_parse_error = true; - memset(m_bufptr, 0, m_length); return false; } @@ -221,7 +230,6 @@ bool hash_base::from_string(const char *&string, int length) if (lower == -1) { m_parse_error = true; - memset(m_bufptr, 0, m_length); return false; } |
