From e4a8df96b1b7ba70ae305e78dc8c8829bf55d9f5 Mon Sep 17 00:00:00 2001 From: John Hodge Date: Thu, 24 Oct 2013 12:21:48 +0800 Subject: [PATCH] UDI/udibuild - Added trim of leading/trailing spaces to inifile --- UDI/Tools/udibuild_src/inifile.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/UDI/Tools/udibuild_src/inifile.c b/UDI/Tools/udibuild_src/inifile.c index d52a845d..50b0684c 100644 --- a/UDI/Tools/udibuild_src/inifile.c +++ b/UDI/Tools/udibuild_src/inifile.c @@ -1,6 +1,7 @@ /* * udibuild - UDI Compilation Utility * - By John Hodge (thePowersGang) + * Part of the Acess2 OS Project * * inifile.c * - .ini file parsing @@ -77,6 +78,8 @@ tIniFile *IniFile_Load(const char *Path) curSect = new_sect; } else if( sscanf(buf, "%[^=]=%n", name, &ofs) >= 1 ) { + rtrim(name); + while( isspace(buf[ofs]) ) ofs ++; //printf("key %s equals %s\n", name, value); const char *value = buf + ofs; tIniFile_Value *val = malloc(sizeof(tIniFile_Value)+strlen(name)+1+strlen(value)+1); @@ -101,6 +104,9 @@ tIniFile *IniFile_Load(const char *Path) const char *IniFile_Get(tIniFile *File, const char *Sect, const char *Key, const char *Default) { + if( !File ) + return Default; + tIniFile_Section *sect; for( sect = &File->RootSection; sect; sect = sect->Next ) { -- 2.20.1