Menu

#1232 nsExec:ExecToLog tab expansion fails with tabs in output

3.0 Series
closed
nobody
None
5
2019-09-15
2019-09-06
Paul Culley
No

The program that was being executed was "fc-cache -fv" with the FC_DEBUG=128 environment variable set. This produced output like the small section below

FC_DEBUG=128
C:/WINDOWS/fonts:   Scanning dir C:/WINDOWS/fonts
    Scanning file C:/WINDOWS/fonts/8514fix.fon...done
    Scanning file C:/WINDOWS/fonts/8514fixe.fon...done
    Scanning file C:/WINDOWS/fonts/8514fixg.fon...done
    Scanning file C:/WINDOWS/fonts/8514fixr.fon...done
    Scanning file C:/WINDOWS/fonts/8514fixt.fon...done
    Scanning file C:/WINDOWS/fonts/8514oem.fon...done
    Scanning file C:/WINDOWS/fonts/8514oeme.fon...done

What might not make it through the bug report is that the first character of each "Scanning" line is a tab character.
3 issues:
1. the tab expansion resulted in large chunks of the output being lost. I isolated this to a bad value for TAB_REPLACE_SIZE, apparently the macro expansion was not correct. This resulted in a NULL being inserted after each tab character, terminating the string improperly.
2. The tab expansion depended on the buffer to contain NULLs to terminate the string, while this worked, I judged it risky. I adjusted so that the string was alway terminated with NULL.
3. The tab expansion was nine characters, instead of eight.

Patch attached that should correct the issues.

1 Attachments

Discussion

  • Anders

    Anders - 2019-09-06

    I'm assuming this only happens in Unicode installers?

     
  • Paul Culley

    Paul Culley - 2019-09-06

    I'm using the mingw64 version of nsis, if I understand your question nsis was built with UNICODE='yes'. I did not test any other versions.

     
    • Anders

      Anders - 2019-09-06

      Built with UNICODE='yes' and "Unicode True" in your .nsi.

       
  • Paul Culley

    Paul Culley - 2019-09-07

    I don't think unicode has anything to do with it. The bug appears to be in the wide character processing for tab expansion which seems (by code inspection) to be independent of any Unicode functionality. My nsi file is very simple and doesn't include any "Unicode True".

    Name "nsExec_Test"
    
    OutFile "nsExec-Test.exe"
    
    ShowInstDetails show
    
    Section "Show failing tab expansion"
        System::Call 'Kernel32::SetEnvironmentVariable(t, t)i ("FC_DEBUG", "128").r0'
        nsExec::ExecToLog '"fc-cache.exe" -fv'
        Pop $0 # return value/error/timeout
        DetailPrint ""
        DetailPrint "       Return value: $0"
        DetailPrint ""
    SectionEnd
    
     
  • Anders

    Anders - 2019-09-15
    • status: open --> closed
     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.