Back to the main page.

Bug 1440 - fixname doesn't parse filename correctly leading to error in warning once

Reported 2012-04-19 11:31:00 +0200
Modified 2012-08-23 10:35:15 +0200
Product: FieldTrip
Component: core
Version: unspecified
Hardware: PC
Operating System: Linux
Importance: P3 critical
Assigned to: Eelke Spaak
Depends on:
See also:

Roemer van der Meij - 2012-04-19 11:31:01 +0200

A simple warning of a undetected filetype should be given, instead, it results in an error: ??? Invalid field name: 'could_not_determine_filetype_of_~_storage_common_dataarx_kahana'. Error in ==> warning_once at 82 previous.(fname).timeout = now+timeout; Error in ==> ft_filetype at 1019 warning_once(sprintf('could not determine filetype of %s', filename)); Eelke, you worked on fixname yesterday right? I set it to critical becauce fixname and warning once are used in so many locations (I think).

Roemer van der Meij - 2012-04-19 11:31:49 +0200

Added Eelke to CC list.

Eelke Spaak - 2012-04-19 11:37:07 +0200

My guess is this was an error before I worked on fixname as well. The ~ in your path name is not replaced by an underscore, therefore it becomes an invalid field name.

Eelke Spaak - 2012-04-19 11:38:11 +0200

506 $ svn commit fixname.m Sending fixname.m Transmitting file data . Committed revision 5661.

Eelke Spaak - 2012-04-19 11:42:11 +0200

Hey, what about using genvarname instead ( in the warning_once function (and possibly elsewhere)? Adding Joern (who originally wrote warning_once) and Robert (who originally wrote fixname) to CC as well, perhaps they had a particular reason for not using genvarname. (BTW, I did change fixname now to also strip ~ characters.)

Roemer van der Meij - 2012-04-19 11:56:05 +0200

Hmmm, private/fixname.m got updated, but /fileio/private/fixname.m didn't. Which is weird, since the autosync property is set. (svn proplist filename) Eelke can you check if both fixname.m's above are the same in your dev-copy?

Roemer van der Meij - 2012-04-19 11:59:20 +0200

Nevermind, there was a conflict in my fixnames, after reverting they both synced properly. Also, bug is confirmed fixed, I closed it. Still though, weird it didn't popup before, those paths (with the home-dir-~) have always been the same.

Eelke Spaak - 2012-04-19 12:01:15 +0200

OK :) Indeed, my fixnames were identical. Closed though this bug may be, the genvarname suggestion above still stands. Why not use that? It also seems nice that that one will be updated by mathworks if the rules for valid names change in future releases.

Robert Oostenveld - 2012-04-19 12:52:52 +0200

(In reply to comment #7) I was not aware of genvarname, that is the only reason why it was not considered. Sounds like a useful function. But looking at it, I find it rather ugly. >> genvarname('jan.mathijs') ans = jan0x2Emathijs All unaccepted characters are replaced by their hexadeximal counterpart, whereas in fixname they are replaced by an underscore. The strategy used in genvarname however is interesting, when compared to fixname. In fixname a list is maintained of all invalid characters that we encountered once upon a time, whereas genvarname does it the other way around and maintains a list of allowed characters. We can replace fixname by something like this >> regexp('jan.Mathijs_is#the$example', '\W') ans = 4 15 19 so str = 'jan.Mathijs_is#the$example'; str(regexp(str, '\W')) = '_'; str = jan_Mathijs_is_the_example should we reopen and do it like this?

Jörn M. Horschig - 2012-04-20 09:43:06 +0200

I didn't look at either function, but there no real need to keep a list of allowed characters, is there? we just need the ascii range (48 to 59 for numbers, 97 to 122 for letters, all characters needs to be lowered)

Jörn M. Horschig - 2012-04-20 10:34:14 +0200

whoops, Robert's solution is similar and more elegant

Robert Oostenveld - 2012-04-20 16:50:23 +0200

(In reply to comment #10) who is going to do it?

Eelke Spaak - 2012-04-20 16:52:21 +0200

Sorry for the silence, I've been busy with non-fieldtrip things (crazy, I know ;) ). I will fix it, it is still in my bug list.

Eelke Spaak - 2012-04-21 07:59:47 +0200

bash-3.2$ svn commit private/fixname.m Sending private/fixname.m Transmitting file data . Committed revision 5685.

Eelke Spaak - 2012-04-21 08:05:28 +0200

I also changed fixname so that it takes care of leading digits: if these are present, an 'x' is prepended to the output string. This is the same behaviour as genvarname.

Eelke Spaak - 2012-08-23 10:35:15 +0200

closing my bugs