Update of /cvsroot/monetdb/pathfinder/compiler/mil
In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv17586
Modified Files:
Tag: XQuery_0-16
milprint_summer.c
Log Message:
Use the MIL function search() instead of the proc locate() to find the
substring in fn:substring-before and fn:substring-after.
But more importantly, check the result to see whether the substring
was found.
Index: milprint_summer.c
===================================================================
RCS file: /cvsroot/monetdb/pathfinder/compiler/mil/milprint_summer.c,v
retrieving revision 1.318.2.12
retrieving revision 1.318.2.13
diff -u -d -r1.318.2.12 -r1.318.2.13
--- milprint_summer.c 17 Feb 2007 01:10:37 -0000 1.318.2.12
+++ milprint_summer.c 20 Feb 2007 09:58:40 -0000 1.318.2.13
@@ -7027,12 +7027,14 @@
counter = prep_str_funs(f, cur_level, counter, args);
milprintf(f,
"{ # fn:substring-before\n"
- "var res := [stringleft](item%s%03u, "
- "[locate](item%s, "
- "item%s%03u).[-](1));\n",
- item_ext, counter,
+ "var search_result%s := [search](item%s%03u, item%s);\n"
+ "var res := [ifthenelse]([<](search_result%s, 0), \"\", "
+ "[stringleft](item%s%03u,
search_result%s));\n"
+ "search_result%s := nil;\n",
+ item_ext, item_ext, counter, item_ext,
item_ext,
- item_ext, counter);
+ item_ext, counter, item_ext,
+ item_ext);
return_str_funs (f, code, cur_level, "fn:substring-before");
deleteResult_ (f, counter, STR);
@@ -7045,17 +7047,17 @@
milprintf(f,
"{ # fn:substring-after\n"
"var length_item%s := [length](item%s);\n"
- "var res := [string](item%s%03u, "
- "[+](length_item%s, "
- "[locate](item%s, "
- "item%s%03u).[-](1)));\n"
- "length_item%s := nil;\n",
- item_ext, item_ext,
- item_ext, counter,
- item_ext,
- item_ext,
- item_ext, counter,
- item_ext);
+ "var search_result%s := [search](item%s%03u, item%s);\n"
+ "var res := [ifthenelse]([<](search_result%s, 0), \"\",
[string](item%s%03u, "
+ "[+](length_item%s,
search_result%s)));\n"
+ "length_item%s := nil;\n"
+ "search_result%s := nil;\n",
+ item_ext, item_ext,
+ item_ext, item_ext, counter, item_ext,
+ item_ext, item_ext, counter,
+ item_ext, item_ext,
+ item_ext,
+ item_ext);
return_str_funs (f, code, cur_level, "fn:substring-after");
deleteResult_ (f, counter, STR);
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Monetdb-pf-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/monetdb-pf-checkins