Add .ini files to backup field of PKGBUILD; Enable expansion of .ini files contents; Add a clean PATH template

This commit is contained in:
David Macek 2015-11-09 23:46:10 +01:00
parent 1a1c5866e0
commit 58b5c72ead
3 changed files with 24 additions and 7 deletions

View File

@ -1,17 +1,18 @@
_realname="msys2-launcher"
pkgname=("${_realname}-git")
pkgver=0.3.15.551bb17
pkgver=0.3.17.1a1c586
pkgrel=1
pkgdesc="Helper for launching MSYS2 shells"
arch=('x86_64' 'i686')
license=('MIT')
backup=({mingw32,mingw64,msys2}.ini)
provides=("${_realname}")
conflicts=("${_realname}")
depends=("mintty>=2.2.1")
makedepends=('mingw-w64-cross-gcc')
source=(launcher.{c,ini,rc} {macros,version}.h Makefile {mingw32,mingw64,msys2}.ico)
md5sums=('052ba00d62b07adca186d57615b43834'
'b7fb06d6faaf530c187b817088228ce6'
md5sums=('e21db11d21f95aab30966a8c528efd9b'
'7ab96cb34fef046e4839e270f9397a32'
'3a3c9fd8d083716e5efd759641eb4f31'
'57a40ae9972dac94df0830a1ab480895'
'fef245f65b6826502b953b81fb397d97'

View File

@ -59,8 +59,10 @@ static PROCESS_INFORMATION StartChild(wchar_t* cmdline) {
static wchar_t* SetEnv(wchar_t* conffile) {
int code;
size_t buflen;
size_t expandedlen;
wchar_t* tmp;
wchar_t* buf;
wchar_t* expanded;
wchar_t* msystem;
FILE* handle;
@ -75,6 +77,8 @@ static wchar_t* SetEnv(wchar_t* conffile) {
buflen = 512;
buf = (wchar_t*)malloc(buflen * sizeof(wchar_t));
*buf = L'\0';
expandedlen = 2 * buflen;
expanded = (wchar_t*)malloc(expandedlen * sizeof(wchar_t));
while (true) {
tmp = fgetws(buf + wcslen(buf), buflen - wcslen(buf), handle);
if (tmp == NULL && !feof(handle)) {
@ -95,15 +99,26 @@ static wchar_t* SetEnv(wchar_t* conffile) {
if (*buf != L'\0' && *buf != L'#') {
tmp = wcschr(buf, L'=');
if (tmp != NULL) {
*tmp = L'\0';
*tmp++ = L'\0';
while (expandedlen < 32768) {
code = ExpandEnvironmentStrings(tmp, expanded, expandedlen);
if ((size_t)code <= expandedlen) {
break;
}
expandedlen *= 2;
expanded = (wchar_t*)realloc(expanded, expandedlen * sizeof(wchar_t));
}
if ((*tmp != L'\0' && code == 0) || (size_t)code > expandedlen) {
ShowLastError(L"Could not expand string");
}
if (0 == wcscmp(L"MSYSTEM", buf)) {
msystem = _wcsdup(tmp + 1);
msystem = _wcsdup(expanded);
if (msystem == NULL) {
ShowError(L"Could not duplicate string", buf, 0);
ShowError(L"Could not duplicate string", expanded, 0);
return NULL;
}
}
code = SetEnvironmentVariable(buf, tmp + 1);
code = SetEnvironmentVariable(buf, expanded);
if (code == 0) {
ShowLastError(L"Could not set environment variable");
}

View File

@ -1,3 +1,4 @@
#MSYS=winsymlinks:nativestrict
#MSYS=error_start:mingw64/bin/qtcreator.exe|-debug|<process-id>
#CHERE_INVOKING=1
#PATH=%SystemRoot%\System32;%SystemRoot%;%SystemRoot%\System32\Wbem