-
Notifications
You must be signed in to change notification settings - Fork 744
Multiple fixes #2299
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Multiple fixes #2299
Conversation
This allows for the correct browsing of files with unicode characters on Windows.
…ases. Also: In preparation for UTF-8 fopen on MINGW/Windows. (Patching gnulib) Note: It turns out the gnulib implementation of select/send/recv causes the UI to be treacle slow (gxdraw.c). So don't use that.
I'm no windows and/or colab user but just wanted to say 👍 on the work |
695f3d8
to
8a0191e
Compare
Thanks. I've briefly tested the collab and autotrace code on Linux, and I don't think there's any (introduced) bugs caused by this. I did fix one segfault bug in the collab code that was unrelated to these changes. P.S: I notice the collab server doesn't close by itself when FontForge closes... I don't think this is caused by me though. |
Remove unused parameter from collab signal The segfault discovered is unrelated to this issue though.
This is part of a portability requirement for working with Unicode filenames on Windows.
On Windows, you can only unlink a file that has no open file handles. So do `fclose` before `unlink`.
This fixes the message: > Failed to rename the new hotkeys file over your old one! > Reason:File exists Reason: 'rename' on Windows is not atomic, and nor will it rename if the destination file exists. Cygwin seems to handle this internally, so this is MINGW specific.
Also: Move ProgramExists->GFileProgramExists (into gutils/fsys.c) Refactoring the autotrace code
Ported using g_spawn_sync as before for autotrace. NB: Not using g_close because it only exists in GLib 2.36, and we can't use g_close on Windows anyway (which is the only platform where this would matter). Add in header for close
I expect to have sometime to look at this on Wednesday. |
All the prototypes in `fileutil.h` already exist in `gfile.h`.
I have switched over all remaining uses of opendir to the GLib equivalents (except in acorn2sfd.c which appears to be a separate program in itself). I also removed the header |
@@ -7612,7 +7606,7 @@ return( NULL ); | |||
free(filename); | |||
|
|||
/* Check if the file exists and is readable */ | |||
if ( access(locfilename,R_OK)!=0 ) { | |||
if ( GFileReadable(locfilename) ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops, should be !GFileReadable
…unction. `GFileModifyable`/`u_GFileModifyable` were never used anywhere. There's no point keeping/maintaining unused functions.
If you need it, just call g_rmdir directly.
Something should be done about the number of character conversion functions available...
Hmm, just going through, why was 5360843 done again? The functions in |
Too often (I mean in general, not FontForge specifically) I see reverted commits without explanatory comment. IMO one should always explain why the revert in the log. |
It does all the original code did, plus it actually works on Windows.
@@ -640,4 +640,4 @@ char *utf82def_copy(const char *ufrom) { | |||
ret = u2def_copy(u2from); | |||
free(u2from); | |||
return( ret ); | |||
} | |||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are we dropping the trailing linebreak?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops, that wasn't intentional.
On Windows, this allows e.g. Cyrillic keyboards to work even if Cyrillic is not currently the active codepage. Related issues: fontforge#1729, fontforge#2290
@@ -25,26 +25,22 @@ | |||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |||
*/ | |||
#include "fontforgevw.h" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a big diff. Would you outline the changes?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's in the comments I made earlier, but briefly:
- Get rid of the Windows specific code path by switching to using GLib
- Port the MetaFont importing function to Windows
@jtanx, I'm not sure about switching every file call to use GLib. It seem ridiculous to me that all of the standard library file handling functions would be broken on Windows. Surely there are other pieces of software that work correctly on Windows using the standard calls (perhaps via some changes to the compilation process)? |
@frank-trampe if you want to support opening files with Unicode filenames, GLib is the easiest way. On Windows, all the standard C library functions assume what is called the multi-byte version of functions. What this means is that they expect filenames (and all other strings for that matter) to be in what is known as the 'current active codepage' - but this is independent of how filenames are represented, so you can always have the case that a particular filename that cannot be represented by the current active codepage. If you look at the Microsoft documentation for say fopen, you'll notice that there is a 'wide-character' version that expects the filename to be encoded in UTF-16 - being Unicode, it works with all filenames. It is for this very reason that internally, GLib must mandate that all strings on Windows for filenames are UTF-8 encoded, and internally they do the re-encode to UTF-16 and then call the wide character version of the functions. For the greatest portability, I think FontForge should be looking into using more of GLib and not less. |
@frank-trampe I plan on splitting this PR to make things easier to merge. |
Some work towards fixing #2290. Also fixes some other bugs along the way.
General direction: Use GLib for all actions that require interaction with the filesystem (still a long long way to go here) where possible.
Rationale: GLib properly handles unicode filenames (on Windows you give it a UTF-8 filename and it does the rest). It's way too much effort to have a separate codepath just for Windows.
This PR includes:
g_signal_new
). Requires testing by someone who uses collab.mkdir_p
(useg_mkdir_with_parents
) andsmprintf
(usexasprintf
)g_spawn_sync
instead. This removes the Windows specific code path.cc @frank-trampe