Bug in RegExPlugin

Jens Teich info at jensteich.de
Mon Dec 23 08:19:10 UTC 2013


diff:

+----------------------------------------------------------------+
diff -u /Users/jens_/Lisp/fm-plugin-tools/main.lisp\~ 
/Users/jens_/Lisp/fm-plugin-tools/main.lisp
--- /Users/jens_/Lisp/fm-plugin-tools/main.lisp~	2012-11-24 
23:03:18.000000000 +0100
+++ /Users/jens_/Lisp/fm-plugin-tools/main.lisp	2013-12-23 
08:50:03.000000000 +0100
@@ -46,7 +46,7 @@
    (with-quadchar (plugin-id *plugin-id*)
      (fm-expr-env-un-register-external-function plugin-id function-id)))

-(defun handle-get-string-message (which-string result-size result-ptr)
+(Defun handle-get-string-message (which-string result-size result-ptr)
    "Handles `kFMXT_GetString' messages from FileMaker.
  WHICH-STRING is the ID for the information FileMaker wants to
  have, RESULT-PTR is where the answer string is supposed to be
@@ -66,8 +66,7 @@
                                     :type :unsigned-short)
            for index from 0 below (1- result-size)
            for char across string
-          do (setf (dereference ptr :index index) (char-code char))
-          finally (setf (dereference ptr :index index) #\Null))))
+          do (setf (dereference ptr :index index) (char-code char)))))

  (defun register-plugin-functions ()
    "Loops through *PLUGIN-FUNCTIONS* and registers with FileMaker

Diff finished.  Mon Dec 23 08:53:17 2013
+----------------------------------------------------------------+


Am 22.12.13 22:58, schrieb Edi Weitz:
> Strange.
>
> 1. If it works without the FINALLY clause, how does FM know where the
> string ends?
>
> 2. ^A is ASCII(1), isn't it?  But we write ASCII(0) there...

don't know, but it works

> On Sun, Dec 22, 2013 at 10:34 PM, Jens Teich <info at jensteich.de> wrote:
>>> 200 times ^A which gave me the clue for the correct solution: no finally
>>> clause at all!
>>
>> Thanks Edi
>>
>> Am 22.12.13 21:45, schrieb Edi Weitz:
>>
>>> Thanks.  What happens if you do this instead?
>>>
>>> (loop with ptr = (make-pointer :address result-ptr
>>>                                      :type :unsigned-short)
>>>             for index from 0 below (1- result-size)
>>>             for char across string
>>>             do (setf (dereference ptr :index index) (char-code char))
>>>             finally (loop for i from index to (1- result-size)
>>>                           do (setf (dereference ptr :index i) #\Null)))
>>>
>>> (Can't test myself.  I don't have a machine with FM on it anymore.)
>>>
>>>
>>>
>>> On Sun, Dec 22, 2013 at 8:31 PM, Jens Teich <info at jensteich.de> wrote:
>>>>
>>>> result-size is 256 always.
>>>>
>>>> Am 22.12.13 13:40, schrieb Edi Weitz:
>>>>
>>>>> @Jens: At first sight, the code looks right to me - or I'm not seeing
>>>>> the forest for the trees.  It could be that FileMaker (maybe only in a
>>>>> specific version or maybe only on the Mac?) ignores the terminating
>>>>> NUL character at the end of the string and expects us to fill the
>>>>> whole buffer?  (Do you happen to know or can you figure out the value
>>>>> of RESULT-SIZE when the function is called?
>>>>>
>>>>> @Russell: We're not as dumb as you might think.  The mailing list
>>>>> information used to be correct and will be correct again.  We're just
>>>>> having a transition phase in which some things are out of sync due to
>>>>> problems with the guy who maintained the common-lisp.net servers.
>>>>>
>>>>> Cheers,
>>>>> Edi.
>>>>>
>>>>>
>>>>>
>>>>> On Sun, Dec 22, 2013 at 12:49 PM, Jens Teich <info at jensteich.de> wrote:
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>> -------- Original-Nachricht --------
>>>>>> Betreff: Re: Bug in RegExPlugin
>>>>>> Datum: Sun, 22 Dec 2013 12:38:59 +0100
>>>>>> Von: Jens Teich <info at jensteich.de>
>>>>>> An: Russell Watson <russell at mrwatson.de>, FM-Lisp+help at common-lisp.net
>>>>>>
>>>>>> Hi Russel,
>>>>>>
>>>>>> thanks for the bug report. This is a tough one (for me). The source of
>>>>>> the problem seems to be here:
>>>>>>
>>>>>> (Defun handle-get-string-message (which-string result-size result-ptr)
>>>>>>      "Handles `kFMXT_GetString' messages from FileMaker.
>>>>>> WHICH-STRING is the ID for the information FileMaker wants to
>>>>>> have, RESULT-PTR is where the answer string is supposed to be
>>>>>> stored, and RESULT-SIZE is the maximal size of the result."
>>>>>>      (when-let (string (case which-string
>>>>>>                          (#.+k-fmxt-name-str+ *plugin-name*)
>>>>>>                          (#.+k-fmxt-app-config-str+ *plugin-help-text*)
>>>>>>                          (#.+k-fmxt-options-str+
>>>>>> (create-options-string))))
>>>>>>        #+:win32
>>>>>>        (convert-to-foreign-string string
>>>>>>                                   :limit (1- result-size)
>>>>>>                                   :external-format :unicode
>>>>>>                                   :into (make-pointer :address
>>>>>> result-ptr
>>>>>>                                                       :type :wchar-t))
>>>>>>        #-:win32
>>>>>>        (loop with ptr = (make-pointer :address result-ptr
>>>>>>                                       :type :unsigned-short)
>>>>>>              for index from 0 below (1- result-size)
>>>>>>              for char across string
>>>>>>              do (setf (dereference ptr :index index) (char-code char))
>>>>>>              finally (setf (dereference ptr :index index) #\Null))))
>>>>>>
>>>>>> ;; from fm-plugin-tools, file main.lisp
>>>>>>
>>>>>> The variable *plugin-name* contains the string "RegExPlugin" and is 11
>>>>>> characters long.
>>>>>>
>>>>>> On Win the problem does not occur so the problem is in the branch after
>>>>>> #-:win32.
>>>>>>
>>>>>> I played a bit with the name of the plugin. When I make it very long,
>>>>>> more unwanted additional characters appear:
>>>>>>
>>>>>> RegexPlugIn***********************************************************
>>>>>> **********************************************************************
>>>>>> **********************************************************************
>>>>>> *********************************************
>>>>>> ￿￿篇ͨe;0.2.4;Disabled
>>>>>>
>>>>>> Maybe the author of this code (Edi Weitz) reads this and can help or I
>>>>>> will ask for help on the LispWorks mailing list.
>>>>>>
>>>>>> ~Jens
>>>>>>
>>>>>> ps Russel: why do you use this old version of the plugin? I improved
>>>>>> the
>>>>>> plugin in the current version according to your input at the FileMaker
>>>>>> Stammtisch some time ago. The RegP-Positions Function has two
>>>>>> additional
>>>>>> parameters now:
>>>>>>
>>>>>> Positions ( regex ; target {; flags ; pairInnerDelimiter ;
>>>>>> pairOuterDelimiter } )
>>>>>>
>>>>>> Am 19.12.13 22:01, schrieb Russell Watson:
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> Hallo Jens / Lisp-developers / RegEx Plugin Entwickler,
>>>>>>>
>>>>>>> ----------------------------------------
>>>>>>> OK - so this is the message in german:
>>>>>>>
>>>>>>> ich habe bemerkt, dass unter fm12 liefert das RegExPlugin bei der Get(
>>>>>>> InstalledPlugins ) Funktion das folgende zurück
>>>>>>>
>>>>>>>                                 ^
>>>>>>> Der kleine Diamant am ende vom Pluginname scheint eine ASCII( 1 )  zu
>>>>>>> sein. Ich nehme an, dass das einen Fehler ist und es in dieser Stelle
>>>>>>> keine ASCII(1) sein soll.
>>>>>>>
>>>>>>> Grüße
>>>>>>>
>>>>>>> Russell Watson (aka MrWatson)
>>>>>>>
>>>>>>>
>>>>>>> ----------------------------------------
>>>>>>> and here again in case you guys only speak english:
>>>>>>>
>>>>>>> Hi,
>>>>>>>
>>>>>>> I use the RegExp FileMaker Plugin, that is available from Jens Teichs
>>>>>>> website under the URL
>>>>>>> http://jensteich.de/wp-content/regex-plugin/RegexPlugIn.zip.
>>>>>>>
>>>>>>> I noticed today, that the plugin returns an ASCII(1) character (the
>>>>>>> little diamond in the picture) in its reply to the FileMaker Get(
>>>>>>> InstalledPlugins ) function.
>>>>>>>
>>>>>>> That I presume is a bug and an undesired character in the plugins
>>>>>>> string.
>>>>>>>
>>>>>>> ----------------------------------------
>>>>>>> An (important) aside:
>>>>>>>
>>>>>>> It is not explicitly clear from the combination of Jens Teichs website
>>>>>>> and the linked Common Lisp "mailing list Informartion" page
>>>>>>> (http://common-lisp.net/cgi-bin/mailman/listinfo/fm-lisp)
>>>>>>>
>>>>>>> 1) if this is the correct email adress that I am writing to
>>>>>>> 2) what the <listname> is of the mailing list for the RegExp plugin -
>>>>>>> is
>>>>>>> it RegExp? is it FM-List*? is it something else?
>>>>>>> 3) which is the correct form of the emailadress: it is mentioned on
>>>>>>> thesss page if it is possible to just write to
>>>>>>> <listname>@common-lisp.net <http://common-lisp.net>
>>>>>>>
>>>>>>>
>>>>>>> I hope that all helps.
>>>>>>>
>>>>>>> Thanks for the Plugin.
>>>>>>>
>>>>>>> Russell Watson (aka MrWatson)
>>>>>>>
>>>>>>>
>>>>>>>      * ...I have just noticed that fm-list is in the url, which
>>>>>>> PROBABLY
>>>>>>> means that <listname>="fm-list"  ... but it needs to be EXPLICIT in at
>>>>>>> least one of the pages ... otherwise you're only going to get emails
>>>>>>> from real nerds. ;-)
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>
>>>>>
>>>>
>>>
>>
>
>




More information about the fm-lisp mailing list