Browse Source

Handle separated hexadecimal characters

If two hexadecimal characters are separated by blanks or comments,
treat them as if they were not separated (as the man page says).
master
Damien Goutte-Gattat 10 years ago
parent
commit
072520f8b3
  1. 18
      src/asysex.c

18
src/asysex.c

@ -101,7 +101,7 @@ read_message_from_file(FILE *in, unsigned char **buffer, size_t *len)
int n, c;
size_t l;
char bytes[3];
enum { NEWLINE, COMMENT, HIGHCHAR, LOWCHAR } state;
enum { NEWLINE, NEWLINE_LOW, COMMENT, COMMENT_LOW, HIGHCHAR, LOWCHAR } state;
n = 0;
bytes[2] = 0;
@ -132,8 +132,15 @@ read_message_from_file(FILE *in, unsigned char **buffer, size_t *len)
}
else if ( c == '\n' )
state = NEWLINE;
else if ( c == '#' )
state = COMMENT;
break;
case NEWLINE_LOW:
if ( c == '#' )
state = COMMENT_LOW;
/* Fall through */
case LOWCHAR:
if ( isxdigit(c) ) {
bytes[1] = c;
@ -147,7 +154,14 @@ read_message_from_file(FILE *in, unsigned char **buffer, size_t *len)
state = HIGHCHAR;
}
else if ( c == '\n' )
state = NEWLINE;
state = NEWLINE_LOW;
else if ( c == '#' )
state = COMMENT_LOW;
break;
case COMMENT_LOW:
if ( c == '\n' )
state = NEWLINE_LOW;
break;
}
}

Loading…
Cancel
Save