- /* pr(int) each character */
- /* we do not need to deal with \-sequences because the
- CQL and PQF terms have same \-format, bug #1988 */
- char buf[2];
-
- buf[0] = term[i];
- buf[1] = '\0';
- (*pr)(buf, client_data);
+ char x[3]; /* temp buffer */
+ if (i > 0 && term[i-1] == '\\')
+ {
+ if (term[i] == '\"' || term[i] == '\\')
+ pr("\\", client_data);
+ if (z3958_mode && strchr("#?", term[i]))
+ pr("\\\\", client_data); /* double \\ to survive PQF parse */
+ x[0] = term[i];
+ x[1] = '\0';
+ pr(x, client_data);
+ }
+ else if (z3958_mode && term[i] == '*')
+ {
+ pr("?", client_data);
+ /* avoid ?n sequences output (n=[0-9]) because that has
+ different semantics than just a single ? in Z39.58
+ */
+ if (i < length - 1 && yaz_isdigit(term[i+1]))
+ pr("\\\\", client_data); /* double \\ to survive PQF parse */
+ }
+ else if (z3958_mode && term[i] == '?')
+ pr("#", client_data);
+ else if (term[i] != '\\')
+ {
+ if (term[i] == '\"')
+ pr("\\", client_data);
+ if (z3958_mode && strchr("#?", term[i]))
+ pr("\\\\", client_data); /* double \\ to survive PQF parse */
+ x[0] = term[i];
+ x[1] = '\0';
+ pr(x, client_data);
+ }