Skip to content

[sfntedit.exe] bug in redirection of help to text file #126

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

Closed
Arno-Enslin opened this issue Apr 9, 2016 · 3 comments
Closed

[sfntedit.exe] bug in redirection of help to text file #126

Arno-Enslin opened this issue Apr 9, 2016 · 3 comments
Assignees
Labels

Comments

@Arno-Enslin
Copy link
Contributor

This results in a 0 byte text file:

@echo off
set "sfnteditCom=C:\FDK_26.03.2016\Tools\win\sfntedit.exe"
%sfnteditCom% -h > tempSfntedit-h.txt&start tempSfntedit-h.txt&ping 127.0.0.1 -n 3 >NUL&del tempSfntedit-h.txt&exit

But this works:

@echo off
set "sfnteditCom=C:\FDK_26.03.2016\Tools\win\sfntedit.exe"
%sfnteditCom% -h 2> tempSfntedit-h.txt&start tempSfntedit-h.txt&ping 127.0.0.1 -n 3 >NUL&del tempSfntedit-h.txt&exit

stdout (standard output) and stderr (standard error output) seem to be messed up.

I would not wonder about this behaviour, if it wouldn't be different from checkoutlines.exe, IS.exe, makeotf.exe, mergeFonts.exe, rotateFont.exe, sfntdiff.exe, Spot.exe and TX.exe, for which ">" only works.

Edit:

Just for fun I will try to fix this by myself, although I don't know anything about C.

main.c in afdko-master\FDK\Tools\Programs\sfntedit\source
looks different from
Dmain.c in afdko-master\afdko-master\FDK\Tools\Programs\sfntdiff\source
with regard to the handling of the output.

At least this looks suspicious in my end user eyes. A few lines from main.c:

    printUsage();
    fprintf(stderr, 
"Notes:\n"
"    This program supports table-editing, listing, and checksumming options\n"
"on sfnt-formatted files such as OpenType Format (OTF) or TrueType. The\n"
"mandatory source file is specified as an argument to the program. An\n"
"optional destination file may also be specified which receives the edited\n"
"data otherwise the source data is edited in-place thus modifying the source\n"
);
[...]
    quit(0); 
    }

Edit 2: It works, if I replace stderr with stdout in main.c. But because it does not work, if I simply delete stderr, I let my fingers on this.

@Arno-Enslin Arno-Enslin changed the title Probably bug in sfntedit.exe with regarding redirection of help to text file Probably bug in sfntedit.exe regarding redirection of help to text file Apr 9, 2016
@readroberts
Copy link
Contributor

I agree the test case shows a bug. I think your fix is correct. It is a simple and safe change, and there is no reason for help and usage text to be sent to stderr. I have little experience on Windows, so I am all for having you testing this case.

@Arno-Enslin
Copy link
Contributor Author

It is a simple and safe change, and there is no reason for help and usage text to be sent to stderr.

I think, that the help should be send to stderr below the error message, if an argument is invalid. And if there is no error, the help should be send to stdout.

I only could replace stderr by stdout. Shall I do that and submit a pull request? Or do you want to fix it by yourself?

By the way (just seen): The behaviour of detype1.exe and type1.exe is also a bit odd with regard to the help and stderr. In both cases it is not directly a help, but only a short usage information. But only in case of type1.exe, you get a short error message ("Unknown Option encountered: -h") above the usage info. I did not find the reason for the different behaviour in the code. But as I have written: I don't know anything about C.

@miguelsousa miguelsousa changed the title Probably bug in sfntedit.exe regarding redirection of help to text file [sfntedit.exe] bug in redirection of help to text file Apr 24, 2018
@readroberts readroberts self-assigned this Aug 13, 2018
@miguelsousa
Copy link
Member

Fixed via #613

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants