[Mumps2Py:] [91] modified translate_intr_find to use Mf_find, as previous code did not correctly handle the 'not-found' case.

[ Thread Index | Date Index | More lists.mumps2py.org/discuss Archives ]


Revision: 91
Author:   pgallot
Date:     2008-02-12 00:12:44 +0000 (Tue, 12 Feb 2008)

Log Message:
-----------
modified translate_intr_find to use Mf_find, as previous code did not correctly handle the 'not-found' case.

Modified Paths:
--------------
    trunk/mumps2py/tok2python.py


Modified: trunk/mumps2py/tok2python.py
===================================================================
--- trunk/mumps2py/tok2python.py	2008-02-12 00:10:34 UTC (rev 90)
+++ trunk/mumps2py/tok2python.py	2008-02-12 00:12:44 UTC (rev 91)
@@ -222,15 +222,16 @@
 
     def translate_intr_find(translation, token):
         """ translates the Mumps Intrinsic function FIND to Python"""
+        translation.add_cl_import()
         search_str = translate_expr(translation, token.params[0])
         sub_str = translate_expr(translation, token.params[1])
         if len(token.params) == 2:
-            find_str = "%s.find(%s) + len(%s) + 1" % \
-                       (search_str, sub_str, sub_str)
+            find_str = "Mf_find(%s, %s)" % \
+                       (search_str, sub_str)
         elif len(token.params) == 3:
             start_str = translate_expr_sub_one(translation, token.params[2])
-            find_str = "%s.find(%s, %s) + len(%s) + 1" % \
-                       (search_str, sub_str, start_str, sub_str)
+            find_str = "Mf_find(%s, %s, %s)" % \
+                       (search_str, sub_str, start_str)
         else:
             raise TranslationError(translation, token,
                                    "incorrect number of parameters")


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/