diff options
Diffstat (limited to 'tool')
| -rw-r--r-- | tool/p8bin2uart.c | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/tool/p8bin2uart.c b/tool/p8bin2uart.c index 944227a..de5a328 100644 --- a/tool/p8bin2uart.c +++ b/tool/p8bin2uart.c | |||
| @@ -146,13 +146,13 @@ print(const char *fmt, ...) | |||
| 146 | va_start(args, fmt); | 146 | va_start(args, fmt); |
| 147 | vsnprintf(tmp, size, fmt, args); | 147 | vsnprintf(tmp, size, fmt, args); |
| 148 | va_end(args); | 148 | va_end(args); |
| 149 | strncat(buf, tmp, MAX_LINE_SIZE * 2 - 1); | 149 | strcat(buf, tmp); |
| 150 | if (strlen(buf) > MAX_LINE_SIZE) { | 150 | if (strlen(buf) > MAX_LINE_SIZE) { |
| 151 | char *space = strrchr(buf, ' '); | 151 | char *space = strrchr(buf, ' '); |
| 152 | assert(space); | 152 | assert(space); |
| 153 | assert(space - buf <= MAX_LINE_SIZE); | 153 | assert(space - buf <= MAX_LINE_SIZE); |
| 154 | *space = 0; | 154 | assert(*space == ' '); |
| 155 | ++space; | 155 | *space++ = '\0'; |
| 156 | assert(strlen(buf) <= MAX_LINE_SIZE); | 156 | assert(strlen(buf) <= MAX_LINE_SIZE); |
| 157 | printf("%s\n", buf); | 157 | printf("%s\n", buf); |
| 158 | memmove(buf, space, buf + sizeof(buf) - space); | 158 | memmove(buf, space, buf + sizeof(buf) - space); |
| @@ -181,18 +181,17 @@ dump(unsigned int wordsperline) | |||
| 181 | if (allzero) continue; | 181 | if (allzero) continue; |
| 182 | if (nextaddr != a) { | 182 | if (nextaddr != a) { |
| 183 | if (nextaddr + wordsperline == a) | 183 | if (nextaddr + wordsperline == a) |
| 184 | print("= "); | 184 | print(" ="); |
| 185 | else | 185 | else |
| 186 | print("!%x ", (unsigned int)((a - nextaddr) / wordsperline)); | 186 | print(" !%x", (unsigned int)((a - nextaddr) / wordsperline)); |
| 187 | } | 187 | } |
| 188 | print("="); | 188 | print(" ="); |
| 189 | for (uint_fast32_t i = 0; i < wordsperline; ++i) | 189 | for (uint_fast32_t i = 0; i < wordsperline; ++i) |
| 190 | print(i == 0 ? "%x" : ":%04x", (unsigned int)words[i]); | 190 | print(i == 0 ? "%x" : ":%04x", (unsigned int)words[i]); |
| 191 | print(" "); | ||
| 192 | nextaddr = a + wordsperline; | 191 | nextaddr = a + wordsperline; |
| 193 | } | 192 | } |
| 194 | if (nextaddr != 32768) | 193 | if (nextaddr != 32768) |
| 195 | print("!%x\n", (unsigned int)((32768 - nextaddr) / wordsperline)); | 194 | print(" !%x\n", (unsigned int)((32768 - nextaddr) / wordsperline)); |
| 196 | flush(); | 195 | flush(); |
| 197 | } | 196 | } |
| 198 | 197 | ||
