[Refdb-cvs] CVS: refdb/src refdbdref.c,1.65.2.11,1.65.2.12
Status: Beta
Brought to you by:
mhoenicka
From: Markus H. <mho...@us...> - 2005-06-12 21:09:40
|
Update of /cvsroot/refdb/refdb/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12022 Modified Files: Tag: Release_0_9_5_stable refdbdref.c Log Message: getref():added support for AX pseudo target; added TX as a synonym for TA pseudo target Index: refdbdref.c =================================================================== RCS file: /cvsroot/refdb/refdb/src/refdbdref.c,v retrieving revision 1.65.2.11 retrieving revision 1.65.2.12 diff -u -U2 -r1.65.2.11 -r1.65.2.12 --- refdbdref.c 9 Jun 2005 19:10:33 -0000 1.65.2.11 +++ refdbdref.c 12 Jun 2005 21:09:29 -0000 1.65.2.12 @@ -2232,4 +2232,7 @@ author_type = 3; } + else if (strncmp(buffer, ":AX:", 4) == 0) { + author_type = 4; + } else { author_type = 0; @@ -2244,4 +2247,7 @@ newtoken = sqltoken.next_token; if (token != NULL) { + char author_type_start[64]; + char author_type_end[4]; + strncpy(buffer, token, sqltoken.length); buffer[sqltoken.length] ='\0'; /* terminate string */ @@ -2250,8 +2256,22 @@ if (token != NULL) { + /* prepare bits and pieces for AND/OR queries*/ + if (author_type == 4) { /* any type of author */ + *author_type_start = '\0'; + strcpy(author_type_end, ") "); + } + else { /* particular type of author */ + sprintf(author_type_start, "(t_xauthor.xauthor_type=%s AND ", get_author_type_string(driver, author_type)); + strcpy(author_type_end, ")) "); + } + /* plain query with one author */ if (*token != '&' && *token != '|') { - sprintf(sql_command, "SELECT DISTINCT t_xauthor.refdb_id FROM t_xauthor, t_author WHERE t_author.author_id=t_xauthor.author_id AND t_xauthor.xauthor_type=%s AND t_author.author_name %s ", get_author_type_string(driver, author_type), (*operator == '=' || (*operator == '!' && *(operator+1) == '=')) ? "=" : my_dbi_conn_get_cap(conn, "rlike")); - + if (author_type == 4) { /* any type of author */ + sprintf(sql_command, "SELECT DISTINCT t_xauthor.refdb_id FROM t_xauthor, t_author WHERE t_author.author_id=t_xauthor.author_id AND t_author.author_name %s ", (*operator == '=' || (*operator == '!' && *(operator+1) == '=')) ? "=" : my_dbi_conn_get_cap(conn, "rlike")); + } + else { /* particular type of author */ + sprintf(sql_command, "SELECT DISTINCT t_xauthor.refdb_id FROM t_xauthor, t_author WHERE t_author.author_id=t_xauthor.author_id AND t_xauthor.xauthor_type=%s AND t_author.author_name %s ", get_author_type_string(driver, author_type), (*operator == '=' || (*operator == '!' && *(operator+1) == '=')) ? "=" : my_dbi_conn_get_cap(conn, "rlike")); + } quoted_token = mstrdup(token); if (!quoted_token) { @@ -2277,5 +2297,5 @@ /* OR query with several authors */ else if (*token == '|') { - sprintf(sql_command, "SELECT DISTINCT t_xauthor.refdb_id FROM t_xauthor, t_author WHERE (t_xauthor.xauthor_type=%s AND (", get_author_type_string(driver, author_type)); + sprintf(sql_command, "SELECT DISTINCT t_xauthor.refdb_id FROM t_xauthor, t_author WHERE %s (", author_type_start); while (token != NULL) { @@ -2331,5 +2351,5 @@ } else { - if ((new_sql_command = mstrcat(sql_command, ")) ", &sql_command_len, 4)) == NULL) { + if ((new_sql_command = mstrcat(sql_command, author_type_end, &sql_command_len, 4)) == NULL) { retval = 1; break; @@ -2356,5 +2376,5 @@ else if (*token == '&') { counter = 0; - sprintf(sql_command, "SELECT DISTINCT t_xauthor.refdb_id, COUNT(*) AS count FROM t_xauthor, t_author WHERE (t_xauthor.xauthor_type=%s AND (", get_author_type_string(driver, author_type)); + sprintf(sql_command, "SELECT DISTINCT t_xauthor.refdb_id, COUNT(*) AS count FROM t_xauthor, t_author WHERE %s (", author_type_start); while (token != NULL) { @@ -2411,5 +2431,5 @@ } else { - if ((new_sql_command = mstrcat(sql_command, ")) ", &sql_command_len, 4)) == NULL) { + if ((new_sql_command = mstrcat(sql_command, author_type_end, &sql_command_len, 4)) == NULL) { retval = 1; break; @@ -2936,5 +2956,6 @@ /*----------------------------------------------------------------*/ /* search in all titles */ - else if (strncmp(token, ":TA:", 4) == 0) { /* all titles query */ + else if (strncmp(token, ":TA:", 4) == 0 /* deprecated */ + || strncmp(token, ":TX:", 4) == 0) { /* all titles query */ char table[3][27] = {"t_refdb.refdb_title", "t_refdb.refdb_booktitle", |