The hash function used to check if a header was of interest always used
its first three characters. For a single-character header that third
byte wasn't particularly set and so it was pot luck if the two hashes
matched, swayed by what was previously in the format string and in the
email's headers. Alter it to cope, including with an empty string.
Comment that it never gives 127 so leaves the last element of the
hash-table array unused. Alter test-header-parsing to stop declaring it
expects to fail.
{ NULL, 0, 0 }
};
-/*
- * Hash function for component name. The function should be
- * case independent and probably shouldn't involve a routine
- * call. This function is pretty good but will not work on
- * single character component names.
- */
-#define CHASH(nm) (((((nm)[0]) - ((nm)[1])) & 0x1f) + (((nm)[2]) & 0x5f))
+/* Hash function for component name. Deliberately avoids a function
+ * call. Is case independent. Covers interval [0, 126] so never uses
+ * the last element of wantcomp[]. This function is "pretty good". */
+#define CHASH(nm) ( \
+ (( \
+ ((nm)[0]) - ((nm)[0] ? ((nm)[1]) : 0) \
+ ) & 0x1f) + \
+ ((nm[1]) ? (((nm)[2]) & 0x5f) : 0) \
+ )
/*
* Find a component in the hash table.
f="`sed 's/:.*/}/; s/^/%{/' "$mail"`"
run_prog scan -forma "$f" -file "$mail" >"$actual" ||
exit 1
-check "$expected" "$actual" expectfail
+check "$expected" "$actual"
exit $failed