* extend the sign bit if the comparison is to be signed */
| 1024 | * extend the sign bit if the comparison is to be signed |
| 1025 | */ |
| 1026 | static unsigned long signextend(server_rec *s, struct magic *m, unsigned long v) |
| 1027 | { |
| 1028 | if (!(m->flag & UNSIGNED)) |
| 1029 | switch (m->type) { |
| 1030 | /* |
| 1031 | * Do not remove the casts below. They are vital. When later |
| 1032 | * compared with the data, the sign extension must have happened. |
| 1033 | */ |
| 1034 | case BYTE: |
| 1035 | v = (char) v; |
| 1036 | break; |
| 1037 | case SHORT: |
| 1038 | case BESHORT: |
| 1039 | case LESHORT: |
| 1040 | v = (short) v; |
| 1041 | break; |
| 1042 | case DATE: |
| 1043 | case BEDATE: |
| 1044 | case LEDATE: |
| 1045 | case LONG: |
| 1046 | case BELONG: |
| 1047 | case LELONG: |
| 1048 | v = (long) v; |
| 1049 | break; |
| 1050 | case STRING: |
| 1051 | break; |
| 1052 | default: |
| 1053 | ap_log_error(APLOG_MARK, APLOG_ERR, 0, s, APLOGNO(01520) |
| 1054 | MODNAME ": can't happen: m->type=%d", m->type); |
| 1055 | return -1; |
| 1056 | } |
| 1057 | return v; |
| 1058 | } |
| 1059 | |
| 1060 | /* |
| 1061 | * parse one line from magic file, put into magic[index++] if valid |
no test coverage detected